Domanda

The Send SMS from Twilio Subaccounts (and yes they are globally enabled message number) functionality not working for me.

Here is the code for sending messages

 public function notification($loggedUserId,$send_to){
    global $objSession;
    $modelUser = new Application_Model_User();      
    $data = $modelUser->getTwilio('twilio',$loggedUserId);
    // here in $data I got all data about subaccount 
     //by which a user is logged in and array i got is
    /* 
    Array
    (
     [twilio_id] => 1
     [twilio_trainer_id] => 147 (its logged user id)
     [twilio_phone] => +177*****09
     [twilio_sid] => ACfd42**********709***b***********
     [twilio_token] => 88a*************************da**
     [twilio_added] => 2014-04-29 19:42:14
    )*/

    // Step 1: Set Library.
    require_once(ROOT_PATH.'/library/twilio/Services/Twilio.php');
    // Step 2: set our AccountSid and AuthToken from www.twilio.com/user/account
    $AccountSid = $data['twilio_sid'];
    $AuthToken = $data['twilio_token'];
    $twilioPhone = $data['twilio_phone'];


    // Step 3: instantiate a new Twilio Rest Client
    $client = new Services_Twilio($AccountSid, $AuthToken);
    // Step 4: make an array of people we know, to send them a message. 
    // Feel free to change/add your own phone number and name here.

    $peopleInfo = $this->objUser->getUserData($send_to); 
    //prd($peopleInfo['user_phone']);

    // Step 5: Loop over all our friends. $number is a phone number above, and 
    // $name is the name next to it


    if(!empty($peopleInfo['user_phone'])){
        $sms = $client->account->messages->sendMessage(
            // Step 6: Change the 'From' number below to be a valid Twilio number 
            // that you've purchased, or the (deprecated) Sandbox number
            $twilioPhone,
            // the number we are sending to - Any phone number
            $peopleInfo['user_phone'],
            // the sms body
            "Hey , Monkey Party at 6PM. Bring Bananas!"
        );
        // Display a confirmation message on the screen
        echo "Sent Successufully ";
    }
    exit;
}

Everything runs fine, but messages are not received on my number. Sent Successfully is printed, but no messages received.

Can anyone see what am i doing wrong ?

È stato utile?

Soluzione

As Requested by Rock Rathore,

Is the class handling area codes? I mean does it need a format? For example if you give it 0091 or +91 or 91 does it matter to it? will the class format the final number even if you send in different formats of area code or does it need one format for the area code?

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top