无法使用Zend Framework通过Twilio Api发送消息

时间:2014-05-09 09:43:01

标签: php zend-framework twilio

来自Twilio Subaccounts的发送短信(以及是全局启用的消息编号)功能对我不起作用。

以下是发送消息的代码

 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;
}

一切正常,但我的号码上没有收到消息。 已成功发送,但未收到任何消息。

谁能看到我做错了什么?

1 个答案:

答案 0 :(得分:0)

正如Rock Rathore所要求的那样,

班级处理区域代码?我的意思是它需要一种格式吗?例如,如果你给它0091或+91或91它是否重要?即使您发送不同格式的区号或者区号需要一种格式,该类格式化最终数字吗?