我有一个类可以访问销售人员中的站点 url。站点 URL“ https://somesalesforce.com/smsToApex ”与 twilio 帐户短信 URL 相同,但无法调用此类。我已经参考了这个文档。twilio SMS url 正确是不是如何检查?Twilio 帐户 SMS url 和 salesforce 站点 url 与现在相同。每当通过 twilio 发送 SMS 时,就会自动在沙箱中创建案例。但这里没有发生.我做正确的生产者不是?。有人可以帮助我。如何解决这个问题。我已经检查了像这样的 twilio 短信网址“ https://somesalesforce.com/service/apexrest/smsToApex ”。我将使用哪个网址提供 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;
}
}