Twilio 如何在php中通过CURL使用twillo notify API发送批量消息?
我想在php中使用CURL使用twillio notify API发送批量消息,我正在尝试以下代码:Twilio 如何在php中通过CURL使用twillo notify API发送批量消息?,twilio,twilio-api,twilio-php,Twilio,Twilio Api,Twilio Php,我想在php中使用CURL使用twillio notify API发送批量消息,我正在尝试以下代码: $data = []; $data['ToBinding'] = array("binding_type"=>"sms", "address"=>"+12013318779"); $data['Body'] ="test"; $ch = curl_init("https://notify.twilio.com/v1/Services/ISXXXXXXXXXX
$data = [];
$data['ToBinding'] = array("binding_type"=>"sms", "address"=>"+12013318779");
$data['Body'] ="test";
$ch = curl_init("https://notify.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXX/Notifications");
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_USERPWD,'XXXXXXXXXXXXXXXXXXX:XXXXXXXXXXXXXXXXXXX');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$resultData = curl_exec($ch);
我认为我对CURLOPT_POSTFIELDS
做了一些错误,但我尝试了每一件事来改变这一点,但每次我都得到以下回应:
{"code": 20001,
"message": "At least one parameter among Identity, Tag, and ToBinding must be specified",
"more_info": "https://www.twilio.com/docs/errors/20001",
"status": 400}
你们能帮帮我吗
感谢这里的Twilio开发者布道者
ToBinding
要求将数据编码为JSON。请尝试以下操作:
$data['ToBinding'] = json_encode(array("binding_type"=>"sms", "address"=>"+12013318779"));
希望有帮助