【发布时间】:2017-08-09 00:59:55
【问题描述】:
那里 我正在使用 Twillio 示例 api
// Step 1: Get the Twilio-PHP library from twilio.com/docs/libraries/php,
// and move it into the folder containing this sendnotifications.php file.
require "Services/Twilio.php";
// Step 2: set our AccountSid and AuthToken from https://twilio.com/console
$AccountSid = "ACea465f2e60ae87332cf47adb0e4aad64";
$AuthToken = "your_auth_token";
// 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.
$people = array(
"+15558675309" => "Curious George",
"+15558675308" => "Boots",
"+15558675307" => "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
"+15017250604",
// 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";
}
这是我的代码
// Step 1: Get the Twilio-PHP library from twilio.com/docs/libraries/php,
// and move it into the folder containing this sendnotifications.php file.
require "Services/Twilio.php";
// Step 2: set our AccountSid and AuthToken from https://twilio.com/console
$AccountSid = "accountsid";
$AuthToken = "authtoken";
// 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.
$people = array(
"my-number-goes-here" => "Ali M. Ayad",
);
// 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
"+13862593325",
// the number we are sending to - Any phone number
$number,
// the sms body
"Hey Ali This is test message form the api"
);
// Display a confirmation message on the screen
echo "Sent message to $name";
}
当我输入此代码并更改身份验证和 id 时,数字是给我的此消息
致命错误:在 C:\AppServ\www\tw\Services\Twilio.php:297 中未捕获的异常“Services_Twilio_RestException”和消息“身份验证错误 - 无效用户名” 堆栈跟踪:#0 C:\AppServ\www\tw \Services\Twilio.php(180): Base_Services_Twilio->_processResponse(Array) #1 C:\AppServ\www\tw\Services\Twilio\ListResource.php(92): Base_Services_Twilio->createData('/2010-04- 01/Acc...', Array) #2 C:\AppServ\www\tw\Services\Twilio\Rest\Messages.php(24): Services_Twilio_ListResource->_create(Array) #3 C:\AppServ\www\ tw\Services\Twilio\Rest\Messages.php(71): Services_Twilio_Rest_Messages->create(Array) #4 C:\AppServ\www\tw\sendnotifications.php(48): Services_Twilio_Rest_Messages->sendMessage('+13862593325', '+201063378955', 'Hey Ali This is...') #5 {main} 在第 297 行的 C:\AppServ\www\tw\Services\Twilio.php 中抛出 我正在使用 appserv
【问题讨论】:
-
非常直接的错误。您是否将您的
AuthToken和AccoundSid放入您可以从您的仪表板获得的?