使用 twilio 通知服务未收到短信,控制台中没有调试错误?

问题描述 投票:0回答:1

我正在尝试使用 Twilio 通知 API 发送批量短信。我查看了文档和其他 StackOverflow 资源,但尚未发现问题。我正在做的是:

$sid = "AC1e590cbb8eee064c3c71axxxxxxxxxxx";
$token = "94c2dc3e2e407c4ebd28cxxxxxxxxxxx";
$twilio = new Client($sid, $token);
$serviceSid = "IS32913ae9b083b809b1c06xxxxxxxxxxx";

$recipients = array();
foreach($phone_nos as $phone_no) {
   array_push($recipients, $phone_no['phone_no']);
}

//recipients array print value is 
//Array
//(
    //[0] => +923105653361
    //[1] => +923491457062
//)

$binding = array();
foreach ($recipients as $recipient) { 
   $binding[] = '{"binding_type":"sms", "address":"'.$recipient.'"}';
}

//binding array is print value is
//Array
//(
    //[0] => {"binding_type":"sms", "address":"+923105653361"}
    //[1] => {"binding_type":"sms", "address":"+923491457062"}
//)

$service = $twilio->notify->v1->services->create();
$notification = $twilio->notify->services($serviceSid)
   ->notifications->create([
   "toBinding" => $binding,
   "body" => 'Test message 5 notify'
]);

echo $notification->body;
echo '<pre>';print_r($notification->sid);exit;

通知控制台显示消息已发送,没有错误。

enter image description here

php twilio sms twilio-api notify
1个回答
1
投票

这里是 Twilio 开发者布道者。

您似乎尚未将消息服务和电话号码连接到您的 Notify 服务。请按照此处文档中的说明进行设置,然后尝试再次发送消息。

© www.soinside.com 2019 - 2024. All rights reserved.