Difference between revisions of "NoAuth usecase 3"

From i2Rest
Jump to: navigation, search
(Undo revision 349 by Pavel.lobko (talk))
(Tag: Undo)
(Undo revision 334 by Alexei.baranov (talk))
(Tag: Undo)
Line 1: Line 1:
 
{{DISPLAYTITLE:Sending SMS via Vonage APIs}}
 
{{DISPLAYTITLE:Sending SMS via Vonage APIs}}
 +
Such a common task as SMS confirmation or any type of VIber/Whatsup messages can be solved pretty easy with the help of numerous web services. Now we will show you how to send SMS from the green screen with the only command using i2Rest client.
 +
Two things we have to take care before start messaging:
 +
: [https://www.nexmo.com registration on Nexmo.com]
 +
: [[adding SSL certificate]]
 +
When the preparations are completed, all we have to do - is just compose our POST request following the [https://developer.nexmo.com/api/sms instructions]. And here is our i2Rest client command:
 +
  I2REST COMMAND(*POST) URL('https://rest.nexmo.com/sms/json')
 +
  BODY(*N 'api_key=40a45a89&api_secret=EN8AHxD6fOd1jvWD&from=VonageSMS API&to=375297784290
 +
  &text=Hello from i2Rest' 'application/x-www-form-urlencoded') OUTPUT(*BOTH) DCMCLIENT(MYCLIENT)
 +
  RECVLOG('/home/btpl/recvnex.log') SENTLOG('/home/btpl/sentnex.log') AUTHMETHOD(*NONE)                                 
 
    
 
    
Two things we have to take care before we start messaging:
+
The same result can be also achieved with <code>application/json</code> request body. The command should look like this:
: [https://www.nexmo.com free registration on Nexmo.com]
+
  I2REST COMMAND(*POST) URL('https://rest.nexmo.com/sms/json')
: [[adding SSL certificate]]
+
  BODY(*N '{"api_key":"40a45a89", "api_secret":"EN8AHxD6fOd1jvWD", "from":"Vonage SMS API",  "to":"375297784290",
 +
  "text":"Hello from i2Rest"}' 'application/json') OUTPUT(*BOTH) DCMCLIENT(MYCLIENT) RECVLOG('/home/btpl/recvnex.log')
 +
  SENTLOG('/home/btpl/sentnex.log') AUTHMETHOD(*NONE)
 +
 
 +
Let's see server response in joblog<br>
 +
[[File:Noauth3-1.png|500px]]
 +
 
  
When the preparations are completed, all we have to do - is just perform POST request with application/json body type.
 
 
 
<pre>
 
I2REST COMMAND(*POST)
 
      URL('https://rest.nexmo.com/sms/json')
 
      BODY(*N '{"api_key":"40a45a89", "api_secret":"EN8AHxD6fOd1jvWD", "from":"Vonage SMS API",  "to":"375297784290", "text":"Hello from i2Rest"}' 'application/json')
 
      OUTPUT(*BOTH)
 
      DCMCLIENT(MYCLIENT)
 
      RECVLOG('/home/btpl/recvnex.log')
 
      SENTLOG('/home/btpl/sentnex.log')
 
      AUTHMETHOD(*NONE)   
 
</pre>
 
 
Was it your phone ring? Check it.<br>
 
Was it your phone ring? Check it.<br>
 
[[File:Noauth3-2.png]]  
 
[[File:Noauth3-2.png]]  
Line 22: Line 25:
  
 
----
 
----
[[I2Rest_Client|Back to i2Rest Client]]
+
[[I2Rest_Client|Back to i2Rest Client]]<br>
 +
[[I2Rest_Client_Usercases|Back to Usecases]]

Revision as of 15:14, 13 April 2020

Such a common task as SMS confirmation or any type of VIber/Whatsup messages can be solved pretty easy with the help of numerous web services. Now we will show you how to send SMS from the green screen with the only command using i2Rest client. Two things we have to take care before start messaging:

registration on Nexmo.com
adding SSL certificate

When the preparations are completed, all we have to do - is just compose our POST request following the instructions. And here is our i2Rest client command:

 I2REST COMMAND(*POST) URL('https://rest.nexmo.com/sms/json') 
 BODY(*N 'api_key=40a45a89&api_secret=EN8AHxD6fOd1jvWD&from=VonageSMS API&to=375297784290
 &text=Hello from i2Rest' 'application/x-www-form-urlencoded') OUTPUT(*BOTH) DCMCLIENT(MYCLIENT)
 RECVLOG('/home/btpl/recvnex.log') SENTLOG('/home/btpl/sentnex.log') AUTHMETHOD(*NONE)                                   
 

The same result can be also achieved with application/json request body. The command should look like this:

 I2REST COMMAND(*POST) URL('https://rest.nexmo.com/sms/json')
 BODY(*N '{"api_key":"40a45a89", "api_secret":"EN8AHxD6fOd1jvWD", "from":"Vonage SMS API",  "to":"375297784290",
 "text":"Hello from i2Rest"}' 'application/json') OUTPUT(*BOTH) DCMCLIENT(MYCLIENT) RECVLOG('/home/btpl/recvnex.log') 
 SENTLOG('/home/btpl/sentnex.log') AUTHMETHOD(*NONE) 

Let's see server response in joblog
Noauth3-1.png


Was it your phone ring? Check it.
Noauth3-2.png



Back to i2Rest Client
Back to Usecases