Difference between revisions of "NoAuth usecase 3"

From i2Rest
Jump to: navigation, search
m (Reverted edits by Pavel.lobko (talk) to last revision by Alexei.baranov)
(Tag: Rollback)
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:
+
Two things we have to take care before we start messaging:
: [https://www.nexmo.com registration on Nexmo.com]
+
: [https://www.nexmo.com free registration on Nexmo.com]
 
: [[adding SSL certificate]]
 
: [[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')
+
When the preparations are completed, all we have to do - is just perform POST request with application/json body type.
  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 <code>application/json</code> request body. The command should look like this:
+
<pre>
  I2REST COMMAND(*POST) URL('https://rest.nexmo.com/sms/json')
+
I2REST COMMAND(*POST)  
  BODY(*N '{"api_key":"40a45a89", "api_secret":"EN8AHxD6fOd1jvWD", "from":"Vonage SMS API",  "to":"375297784290",
+
      URL('https://rest.nexmo.com/sms/json')
  "text":"Hello from i2Rest"}' 'application/json') OUTPUT(*BOTH) DCMCLIENT(MYCLIENT) RECVLOG('/home/btpl/recvnex.log')  
+
      BODY(*N '{"api_key":"40a45a89", "api_secret":"EN8AHxD6fOd1jvWD", "from":"Vonage SMS API",  "to":"375297784290", "text":"Hello from i2Rest"}' 'application/json')  
  SENTLOG('/home/btpl/sentnex.log') AUTHMETHOD(*NONE)  
+
      OUTPUT(*BOTH)
 
+
      DCMCLIENT(MYCLIENT)  
Let's see server response in joblog<br>
+
      RECVLOG('/home/btpl/recvnex.log')  
[[File:Noauth3-1.png|500px]]
+
      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 25: Line 22:
  
 
----
 
----
[[I2Rest_Client|Back to i2Rest Client]]<br>
+
[[I2Rest_Client|Back to i2Rest Client]]
[[I2Rest_Client_Usercases|Back to Usecases]]
 

Revision as of 11:09, 13 April 2020


Two things we have to take care before we start messaging:

free registration on Nexmo.com
adding SSL certificate

When the preparations are completed, all we have to do - is just perform POST request with application/json body type.

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)    

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



Back to i2Rest Client