Unable to Receive the SMS via twilio

♀尐吖头ヾ 提交于 2019-12-19 04:21:46

问题


I have twilio phone number,Visual force page and Controller.I have reference Document I have followed.I send an sms via twilio but unable to receive the sms. Customer Send an sms to twilio number it can revert back the sms but unable to receive the sms details in Salesforce Apex

Visual force page

<apex:page controller="TwilioRequestControllerContacts" action="{!init}" showHeader="false" sidebar="false">
    <center>
        <apex:pageBlock title="Twilio Request Listener"></apex:pageBlock>          
    </center>
</apex:page>

Controller

public with sharing class TwilioRequestControllerContacts 
    {
        public String fromNumber      = ApexPages.currentPage().getParameters().get('From');
        public String toNumber        = ApexPages.currentPage().getParameters().get('To');
        public String body            = ApexPages.currentPage().getParameters().get('Body');
        public PageReference init()
        {
        try
        {           
           System.debug('STEP 0 FROM: ==========>' + fromNumber); 
           System.debug('STEP 1 TO: ===============>' + toNumber);
           System.debug('STEP 2 BODY: ==========>' + body); 
IF(fromNumber != NULL && toNumber = !NULL){
Case c = new Case(Subject = toNumber+fromNumber,Description =body);
insert c;
}

          }
catch(exception e){}
        RETURN null;
       }  
    }

Here SMS conformation sent dynamically while customer send an sms it is ok. But unable to receive the SMS details. I am doing correct way or not can some one please help me


回答1:


The first thing you should do is to login to the Twilio console, go to Devtools | App Monitor, and see what Twilio thinks is happening.

The most likely problem is that Twilio is getting a 404 error when it tries to access your Visualforce page. You must add the page to a Force.com Site for it to be publicly visible. A quick test is to just paste your Visualforce page URL into the browser and try to view it - you should see the 'Twilio Request Listener' page block.

To make the page visible, create a Force.com Site (if you have not already done so), then, on the Site configuration, add the Visualforce page to the Site Visualforce Pages list. You should now be able to see the page in the browser, and Twilio should be able to access it.




回答2:


Finally I have created a Case while Customer Sent an SMS twilio Phone number.

Steps:

  • After installing Twilio in Sandbox, we need to create a Visualforce page and one Controller as specified.
  • Create a Force.com Site and add your Visualforce page to your site. Then give the site url(https://sandbox.force.com/sms).

Path :Setup > Developer > "New"

Note : The Site Url and Twilio Account SMS Url must and should be same other wise the HTTP post request will not post to your Visualforce page.

  • Give the Site access to the Controller and the Case Object. From the Site detail page, click Public Access Settings to visit the Site's guest user profile. Enable Read and Edit access on the Case Object. Add the controller Apex Class to the Enabled Apex Class Access list.
  • Create a Remote Site Settings in Sandbox i.e Endpoint Url for the Twilio API.

Path :Setup > Administer > Security Controls > Remote Site Settings > "New Remote Site"

Then send an SMS to your Twilio phone number. It will create a new case in the Sandbox. It is amazing concept of Twilio API for the Salesforce.



来源:https://stackoverflow.com/questions/24339900/unable-to-receive-the-sms-via-twilio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!