我有一个可以访问salesforce中的网站网址的课程。 网站网址" https://somesalesforce.com/smsToApex"和twilio帐户短信网址相同,但不能调用此类。 我已经参考this document。twilio短信网址正确不是如何检查?Twilio帐户短信网址和salesforce网站网址与现在相同。无论什么时候短信来自twilio然后自动Case在沙盒中创建。但这里没有发生。我做正确的制作人不是吗?。有人请帮助我。如何解决这个问题。我已经检查了这样的twilio短信网址" https://somesalesforce.com/service/apexrest/smsToApex&#34 ; .which url我将同时提供Salesforce站点URL,Twilio SMS URL。
@RestResource(urlMapping='/smsToApex')
global class smsToApex
{
Static TwilioAccount account = TwilioAPI.getDefaultAccount();
@HttpPost
global static void incomingSMS()
{
// This will error out with System.LimitException if we would exceed
// our daily email limit
Messaging.reserveSingleEmailCapacity(1);
String expectedSignature = RestContext.request.headers.get('X-Twilio-Signature');
system.debug('ES' + expectedSignature);
String url = 'https://' + RestContext.request.headers.get('Host') + '/services/apexrest' + RestContext.request.requestURI;
Map <String, String> params = RestContext.request.params;
system.debug('smsToApex========>'+params);
// Validate signature
if (!TwilioAPI.getDefaultClient().validateRequest(expectedSignature, url, params)) {
RestContext.response.statusCode = 403;
RestContext.response.responseBody = Blob.valueOf('Failure! Rcvd '+expectedSignature+'\nURL '+url/*+'\nHeaders'+RestContext.request.headers*/);
return;
}
RestContext.response.responseBody = Blob.valueOf('ok');
String caseFrom = params.get('From');
String caseTo = params.get('To');
String caseBody = params.get('Body');
System.debug('Step 4 smsToApex caseFrom==>'+caseFrom);
System.debug('Step 5 smsToApex caseTo===>'+caseTo);
System.debug('Step 6 smsToApex caseBody===>'+caseBody);
Case ca = new Case();
ca.Subject = 'Test smsToApex caseFrom'+caseFrom;
ca.Description = 'Test smsToApex caseBody'+caseBody+','+caseTo;
ca.Origin = 'Phone';
INSERT ca;
}
}
答案 0 :(得分:0)
要检查的一些事情......