You need to sign in to do that
Don't have an account?
REST API Integration to send sms
Hi
We want to send an sms from Salesforce to Mobile through REST API
we used this code
Http http = new Http(); HttpRequest req = new HttpRequest();
req.setEndpoint('https://Account ID:Auth token@api.twilio.com/2010-04-01/Accounts');
req.setMethod('GET');
String username = 'xxxxxxxxxxxxxxxxxx';
String password = 'yyyyyyyyyyyyyyyyyyy';
Blob headerValue = Blob.valueOf(username + ':' + password);
String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
req.setHeader('Authorization', authorizationHeader);
req.setBody('hai'); HTTPResponse res = http.send(req);
System.debug('STATUS:'+res.getStatus());
System.debug('STATUS_CODE:'+res.getStatusCode());
System.debug('----Responce----'+res.getBody());
but it gives status 401 notfound error how can we do Plz help me
how can we overcome this, Please post your reply at earliest.
It looks like you're trying to do basic authentication in two places. Try changing your second line of code to
Hi Charan,
Did you solve this issue... If solve, can you tell me please how can i send sms to mobiles through salesforce. Please help me.
Thanks,
Lakshmi
Please try this....!!
String account = 'Your twilio Account Sid';
String token = 'Your twilio Auth token';
HttpRequest req = new HttpRequest();
req.setHeader('X-Twilio-Client', 'salesforce-' + '2010-04-01');
req.setHeader('User-Agent', 'twilio-salesforce-' + '2010-04-01');
req.setHeader('Content-Type', 'Application/JSON');
req.setHeader('Authorization', 'Basic '+ EncodingUtil.base64Encode(Blob.valueOf(account + ':' +token )));
req.setEndpoint('https://api.twilio.com'+'/'+'2010-04-01'+'/Accounts/'+account+'/SMS/Messages.json');
req.setMethod('POST');
req.setBody(''
+ 'From=' + EncodingUtil.urlEncode('+14242752341', 'UTF-8')
+ '&To=' + EncodingUtil.urlEncode(recievernumber, 'UTF-8')
+ '&Body=' + EncodingUtil.urlEncode('Type Message here', 'UTF-8')
);
HttpResponse res = new Http().send(req);
//check response
if (res.getStatusCode() >= 200 && res.getStatusCode() < 300) {
System.debug('This is the response '+res.getBody());
}
MsgClub (http://www.msgclub.net/)’s SMS API integration allows you to integrate SMS services with the Salesforce software you use. In this highly competitive online environment, having SMS API integration in Salesforce software is proving to be a measurable advantage.