Difference between revisions of "NoAuth usecase 3"

From i2Rest
Jump to: navigation, search
m
 
(7 intermediate revisions by 2 users not shown)
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/Whatsapp 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.
+
Such a common task as SMS confirmation or any type of Viber/Whatsapp 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|i2Rest Client]].
 
Two things we have to take care before start messaging:
 
Two things we have to take care before start messaging:
: [https://www.nexmo.com registration on Nexmo.com]
+
* [https://www.nexmo.com registration on Nexmo.com]
: adding Nexmo.com SSL certificate CA to your DCM - see [[Add_external_CA_to_trust_list|"how to" instructions]]
+
* adding Nexmo.com SSL certificate CA to your DCM - see [[Add_external_CA_to_trust_list|"how to" instructions]]
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:
+
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')  
+
<pre>
  BODY(*N 'api_key=<your_nexmo_api_secret>&api_secret=<your_nexmo_api_secret>&from=Vonage%20SMS%20API&to=<your_telephone_number>
+
I2REST COMMAND(*POST)                                      
    &text=Hello%20from%20i2Rest' 'application/x-www-form-urlencoded')  
+
      URL('https://rest.nexmo.com/sms/json')              
  OUTPUT(*BOTH)  
+
      BODY(*N 'api_key=<your_api_key>&api_secret=<your_api_secret>
  DCMCLIENT(MYCLIENT)
+
            &from=Vonage%20SMS%20API&text=Hello%20from%20i2R
  RECVLOG('/home/btpl/recvnex.log')  
+
            est&to=<Your_phone_number>' 'application/x-www-form-url
  SENTLOG('/home/btpl/sentnex.log')  
+
            encoded')                                      
  AUTHMETHOD(*NONE)                                  
+
      OUTPUT(*BOTH)                                      
 
+
      DCMCLIENT(<your_DCM_client>)                                
 +
      RECVLOG('/home/logs/SMS.log')                  
 +
      SENTLOG('/home/logs/SMS.log')                  
 +
      AUTHMETHOD(*NONE)                                                                                                        
 +
</pre> 
 
The same result can be also achieved with <code>application/json</code> request body. The command should look like this:
 
The same result can be also achieved with <code>application/json</code> request body. The command should look like this:
  I2REST COMMAND(*POST) URL('https://rest.nexmo.com/sms/json')
+
<pre>
  BODY(*N '{"api_key":"<your_nexmo_api_key"api_secret":"<your_nexmo_api_secret>", "from":"Vonage SMS API", "to":"<your_telephone_number>",
+
I2REST COMMAND(*POST)  
    "text":"Hello from i2Rest"}' 'application/json')  
+
      URL('https://rest.nexmo.com/sms/json')
  OUTPUT(*BOTH)  
+
      BODY(*N  
  DCMCLIENT(MYCLIENT)
+
            '{"api_key":"<your_api_key>",
  RECVLOG('/home/logs/recvnex.log')  
+
              "api_secret":"<your_api_secret>",  
  SENTLOG('/home/logs/sentnex.log')  
+
              "from":"Vonage SMS API",  
  AUTHMETHOD(*NONE)  
+
              "to":"<your_phone_number>",
 +
              "text":"Hello from i2Rest"}'  
 +
            'application/json')  
 +
      OUTPUT(*BOTH)  
 +
      DCMCLIENT(<your_DCM_client>)
 +
      RECVLOG('/home/logs/SMS.log')                  
 +
      SENTLOG('/home/logs/SMS.log')  
 +
      AUTHMETHOD(*NONE)  
 +
</pre>
 +
Let's see server response in SMS.log.<br>
 +
<pre>
 +
Server response (status 200, shown 259 bytes of 259):         
 +
{                                                             
 +
    "message-count": "1",                                     
 +
    "messages": [{                                           
 +
        "to": "123456789100",                                 
 +
        "message-id": "13000000E084F19C",                     
 +
        "status": "0",                                       
 +
        "remaining-balance": "1.27900000",                   
 +
        "message-price": "0.10300000",                       
 +
        "network": "25702"                                   
 +
    }]                                                       
 +
}                                                             
 +
</pre>
  
Let's see server response in joblog<br>
 
Хорошо бы замазать номер телефона ->
 
[[File:Noauth3-1.png|500px]]
 
 
 
 
Хорошо бы убрать текст "5 мин." ->
 
 
Was it your phone ring? Check it.<br>
 
Was it your phone ring? Check it.<br>
[[File:Noauth3-2.png]]
+
[[File:Noauth3-2.png]]
 
 
 
 
----
 
[[I2Rest_Client|Back to i2Rest Client]]<br>
 
[[I2Rest_Client_Usercases|Back to Usecases]]
 

Latest revision as of 21:57, 16 July 2020

Such a common task as SMS confirmation or any type of Viber/Whatsapp 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:

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=<your_api_key>&api_secret=<your_api_secret>
            &from=Vonage%20SMS%20API&text=Hello%20from%20i2R
            est&to=<Your_phone_number>' 'application/x-www-form-url
            encoded')                                       
       OUTPUT(*BOTH)                                        
       DCMCLIENT(<your_DCM_client>)                                 
       RECVLOG('/home/logs/SMS.log')                    
       SENTLOG('/home/logs/SMS.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":"<your_api_key>", 
              "api_secret":"<your_api_secret>", 
              "from":"Vonage SMS API", 
              "to":"<your_phone_number>",
              "text":"Hello from i2Rest"}' 
            'application/json') 
       OUTPUT(*BOTH) 
       DCMCLIENT(<your_DCM_client>)
       RECVLOG('/home/logs/SMS.log')                    
       SENTLOG('/home/logs/SMS.log') 
       AUTHMETHOD(*NONE) 

Let's see server response in SMS.log.

 Server response (status 200, shown 259 bytes of 259):          
 {                                                              
     "message-count": "1",                                      
     "messages": [{                                             
         "to": "123456789100",                                  
         "message-id": "13000000E084F19C",                      
         "status": "0",                                         
         "remaining-balance": "1.27900000",                     
         "message-price": "0.10300000",                         
         "network": "25702"                                     
     }]                                                         
 }                                                              

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