Я настраиваю файл Twilio sendnotifications.php, как описано на этом веб-сайте
Когда я запускаю "php sendnotifications.php" в терминале с этим кодом, все работает отлично, и яполучить мое SMS
<?php
// Required if your environment does not handle autoloading
require __DIR__ . '/Twilio/autoload.php';
// Use the REST API Client to make requests to the Twilio REST API
use Twilio\Rest\Client;
// Your Account SID and Auth Token from twilio.com/console
$sid = 'My id';
$token = 'My token';
$client = new Client($sid, $token);
// Use the client to do fun stuff like send text messages!
$client->messages->create(
// the number you'd like to send the message to
'MyPhoneNumber',
array(
// A Twilio phone number you purchased at twilio.com/console
'from' => 'MyTwilioSendingNumber',
// the body of the text message you'd like to send
'body' => "My message"
)
);
Но когда я запускаю его так, у меня появляется ошибка:
<?php
// Required if your environment does not handle autoloading
require __DIR__ . '/Twilio/autoload.php';
// Use the REST API Client to make requests to the Twilio REST API
use Twilio\Rest\Client;
// Your Account SID and Auth Token from twilio.com/console
$sid = 'My id';
$token = 'My token';
$client = new Client($sid, $token);
$phone='MyPhoneNumber';
// Use the client to do fun stuff like send text messages!
$client->messages->create(
// the number you'd like to send the message to
$phone,
array(
// A Twilio phone number you purchased at twilio.com/console
'from' => 'MyTwilioSendingNumber',
// the body of the text message you'd like to send
'body' => "My message"
)
);
Ошибка:
MacBook-Pro:Test envoi sms accueil Joris$ php sendnotifications.php
Fatal error: Uncaught Twilio\Exceptions\RestException: [HTTP 400] Unable to create record: The 'To' number 74663 is not a valid phone number. in /Users/Joris/Desktop/Test envoi sms accueil/Twilio/Version.php:85
Stack trace:
#0 /Users/Joris/Desktop/Test envoi sms accueil/Twilio/Version.php(219): Twilio\Version->exception(Object(Twilio\Http\Response), 'Unable to creat...')
#1 /Users/Joris/Desktop/Test envoi sms accueil/Twilio/Rest/Api/V2010/Account/MessageList.php(69): Twilio\Version->create('POST', '/Accounts/AC8ec...', Array, Array)
#2 /Users/Joris/Desktop/Test envoi sms accueil/sendnotifications.php(20): Twilio\Rest\Api\V2010\Account\MessageList->create('$phone', Object(Twilio\Values))
#3 {main}
thrown in /Users/Joris/Desktop/Test envoi sms accueil/Twilio/Version.php on line 85
MacBook-Pro:Test envoi sms accueil Joris$