【发布时间】:2015-06-13 20:29:03
【问题描述】:
根据 Twilio 和 Curl 的文档,我有一个 php curl 例程:
function twilio($mobile,$msg,$twoCode){
$url = 'https://api.twilio.com/2010-04-01/Accounts/'.TWILIO_ACCOUNT_SID.'/Calls.json';
$CallURL = 'http://Myweb.com/code/say/'.$twoCode;
$auth = TWILIO_ACCOUNT_SID.":".TWILIO_AUTH_TOKEN;
$fields = array(
'To' => $mobile ,
'From' => '+16262471234' , // My Number
'Url' => urlencode( $CallURL ) ,
'Method'=>'GET' ,
'FallbackMethod'=>'GET',
'StatusCallbackMethod'=>'GET',
'Record'=>'false'
);
$post = http_build_query($fields);
$curl = curl_init($url);
// Set some options - we are passing in a useragent too here
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_USERAGENT , 'Mozilla 5.0');
curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Length: 7' ));
curl_setopt($curl, CURLOPT_USERPWD, $auth);
curl_setopt($curl, CURLOPT_VERBOSE , true);
$resp = curl_exec($curl);
curl_close($curl);
}
它给了我一个错误:
{"code": 21213, "message": "No 'From' number is specified", "more_info": "https://www.twilio.com/docs/errors/21213", "status": 400}
我尝试了所有选项,有人可以帮忙吗?
我编辑并为“发件人”号码添加了一个“+”。但是错误仍然是一样的。
提前致谢!
【问题讨论】:
-
好像没有国家代码
+NN或0NNfrom number -
我编辑并为“From”编号添加了“+”,错误仍然保持不变,
-
您添加了国家代码吗?
-
是的,我在我的 Twilio 电话号码中添加了“+1”
标签: php curl twilio phone-call