Advertisement
Guest User

Untitled

a guest
Feb 7th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. global void sendsms()
  2. {
  3. String username = 'JRjNX4xr0yQDTndP9vfa' ;
  4. String password = 'vyAK$ja7NhLOcI8pX34lokMxUue0RZ.i';
  5. String message= 'Hi this msg. is for testing of "sending msg.on mobile when SLA breach"';
  6. HttpRequest req = new HttpRequest();
  7. req.setEndpoint('https://api.us1.corvisa.io/sms/send');
  8. req.setMethod('POST');
  9. String phonenumber='+15123355101';
  10. //String body='{"text":" '+message+'","to_number":"'+phoneNumber+'"}';
  11. //String body='{"text": "Test Message","to_number": "+15123355101"}';
  12. //String body='{"messages"":""Hi this is for test","to_number"":" "+15123355101"}';
  13. String body='{"messages": [{"text": "text of message","to_number": "+15123355101"}]}';
  14. Blob headerValue = Blob.valueOf(username + ':' + password);
  15. String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
  16. req.setHeader('Authorization', authorizationHeader);
  17. req.setHeader('Content-Type','application/json');
  18. HTTPResponse res= new HTTPResponse();
  19. req.setBody(body);
  20. Http http = new Http();
  21. //res.setStatusCode(200);
  22. res = http.send(req);
  23. system.debug(res.toString());
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement