twilio 未捕获的异常错误
twilio Uncaught exception error
Twilio 新手使用测试帐户。我按照此处列出的说明安装 Twilio php:
https://www.twilio.com/docs/quickstart/php/sms
因为我收到证书错误,我的主机提供商建议我更改 CURLOPT_SSL_VERIFYPEER => false(原为 true)。但是现在我收到了这个错误。怎么修?:
致命错误:
中的消息 'The requested resource /2010-04-01/Accounts//Messages.json was not found' 未捕获异常 'Services_Twilio_RestException'
require "Services/Twilio.php";
// Step 2: set our AccountSid and AuthToken from www.twilio.com/user/account
$AccountSid = "ACbxxxxxxx";
$AuthToken = "0cfxxxxxxx";
// Step 3: instantiate a new Twilio Rest Client
//$client = new Services_Twilio($AccountSid, $AuthToken);
$http = new Services_Twilio_TinyHttp(
'https://api.twilio.com',
array('curlopts' => array(
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => 2,
))
);
$client = new Services_Twilio($sid, $token, "2010-04-01", $http);
// 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.
$people = array(
"+13121111111" => "Curious George",
// "+14158675311" => "Virgil",
);
// Step 5: Loop over all our friends. $number is a phone number above, and
// $name is the name next to it
foreach ($people as $number => $name) {
$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
"929-xxx-xxxx",
// the number we are sending to - Any phone number
$number,
// the sms body
"Hey $name, Monkey Party at 6PM. Bring Bananas!"
);
// Display a confirmation message on the screen
echo "Sent message to $name";
}
此处为 Twilio 开发人员布道师。
首先,你不应该在生产环境中将 CURLOPT_SSL_VERIFYPEER
设置为 false。来自 curl manual:
WARNING: disabling verification of the certificate allows bad guys to man-in-the-middle the communication without you knowing it. Disabling verification makes the communication insecure. Just having encryption on a transfer is not enough as you cannot be sure that you are communicating with the correct end-point.
为了让您使用 Twilio,尽管您的问题出在您使用的变量名上。
在您设置的文件顶部:
$AccountSid = "ACbxxxxxxx";
$AuthToken = "0cfxxxxxxx";
但是当您创建 Twilio 时,您使用 $sid
和 $token
。
$client = new Services_Twilio($sid, $token, "2010-04-01", $http);
如果将它们更改为 $AccountSid
和 $AuthToken
,它应该会按预期工作。
Twilio 新手使用测试帐户。我按照此处列出的说明安装 Twilio php: https://www.twilio.com/docs/quickstart/php/sms
因为我收到证书错误,我的主机提供商建议我更改 CURLOPT_SSL_VERIFYPEER => false(原为 true)。但是现在我收到了这个错误。怎么修?: 致命错误:
中的消息 'The requested resource /2010-04-01/Accounts//Messages.json was not found' 未捕获异常 'Services_Twilio_RestException'require "Services/Twilio.php";
// Step 2: set our AccountSid and AuthToken from www.twilio.com/user/account
$AccountSid = "ACbxxxxxxx";
$AuthToken = "0cfxxxxxxx";
// Step 3: instantiate a new Twilio Rest Client
//$client = new Services_Twilio($AccountSid, $AuthToken);
$http = new Services_Twilio_TinyHttp(
'https://api.twilio.com',
array('curlopts' => array(
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => 2,
))
);
$client = new Services_Twilio($sid, $token, "2010-04-01", $http);
// 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.
$people = array(
"+13121111111" => "Curious George",
// "+14158675311" => "Virgil",
);
// Step 5: Loop over all our friends. $number is a phone number above, and
// $name is the name next to it
foreach ($people as $number => $name) {
$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
"929-xxx-xxxx",
// the number we are sending to - Any phone number
$number,
// the sms body
"Hey $name, Monkey Party at 6PM. Bring Bananas!"
);
// Display a confirmation message on the screen
echo "Sent message to $name";
}
此处为 Twilio 开发人员布道师。
首先,你不应该在生产环境中将 CURLOPT_SSL_VERIFYPEER
设置为 false。来自 curl manual:
WARNING: disabling verification of the certificate allows bad guys to man-in-the-middle the communication without you knowing it. Disabling verification makes the communication insecure. Just having encryption on a transfer is not enough as you cannot be sure that you are communicating with the correct end-point.
为了让您使用 Twilio,尽管您的问题出在您使用的变量名上。
在您设置的文件顶部:
$AccountSid = "ACbxxxxxxx";
$AuthToken = "0cfxxxxxxx";
但是当您创建 Twilio 时,您使用 $sid
和 $token
。
$client = new Services_Twilio($sid, $token, "2010-04-01", $http);
如果将它们更改为 $AccountSid
和 $AuthToken
,它应该会按预期工作。