Twilio 发送短信
Twilio send an sms
您好,我必须在我的应用程序中验证用户 phone 号码。我已经实现了 twilio 库,但无法发送短信。我收到这个错误
Uncaught exception 'Services_Twilio_RestException' with message 'The From phone number +120xxxxxxx is not a valid, SMS-capable inbound phone number or short code for your account
我还没有购买他们的订阅。我想先测试他们的服务,所以我使用的是试用帐户。我用过 test AccountSID
和 Test authToken
。
<?php
require "twilio/Services/Twilio.php";
// set your AccountSid and AuthToken from www.twilio.com/user/account
$AccountSid = "testaccountsid";
$AuthToken = "testauthtoken";
$client = new Services_Twilio($AccountSid, $AuthToken);
$message = $client->account->messages->create(array(
"From" => "+1xxxxxxxx",
"To" => "+92xxxxxxx",
"Body" => "Test message!",
));
// Display a confirmation message on the screen
echo "Sent message {$message->sid}";
发件人: 当我点击 Get your first twilio phone number
他们给了我一个美国手机号码,我在发件人字段中使用了这个号码
To: 这里我用了自己的号码,这样我就可以收到短信了。我自己的号码在twilio中也被用于验证目的
我基本上想使用 twilio 从“6323”之类的数字发送随机 PIN 码。请告诉我我错过了什么。他们还给了我在发件人字段中使用的美国号码。如何在“发件人”字段中获取像“6323”这样的短号码或像 "whatsapp" 这样的字母名称。
根据 docs:
Test Credentials
If you received this error while trying to authenticate with your Test Credentials, you probably tried to send a message with a From number from your live account. The only number that can be used to send successful messages with your Test Credentials is +15005550006. For more information, read our documentation on the From number for sending SMS with your test credentials.
因此您需要将 +15005550006
硬编码为 From
。
有关他们 API 的更多信息,请参阅 this
您好,我必须在我的应用程序中验证用户 phone 号码。我已经实现了 twilio 库,但无法发送短信。我收到这个错误
Uncaught exception 'Services_Twilio_RestException' with message 'The From phone number +120xxxxxxx is not a valid, SMS-capable inbound phone number or short code for your account
我还没有购买他们的订阅。我想先测试他们的服务,所以我使用的是试用帐户。我用过 test AccountSID
和 Test authToken
。
<?php
require "twilio/Services/Twilio.php";
// set your AccountSid and AuthToken from www.twilio.com/user/account
$AccountSid = "testaccountsid";
$AuthToken = "testauthtoken";
$client = new Services_Twilio($AccountSid, $AuthToken);
$message = $client->account->messages->create(array(
"From" => "+1xxxxxxxx",
"To" => "+92xxxxxxx",
"Body" => "Test message!",
));
// Display a confirmation message on the screen
echo "Sent message {$message->sid}";
发件人: 当我点击 Get your first twilio phone number
他们给了我一个美国手机号码,我在发件人字段中使用了这个号码
To: 这里我用了自己的号码,这样我就可以收到短信了。我自己的号码在twilio中也被用于验证目的
我基本上想使用 twilio 从“6323”之类的数字发送随机 PIN 码。请告诉我我错过了什么。他们还给了我在发件人字段中使用的美国号码。如何在“发件人”字段中获取像“6323”这样的短号码或像 "whatsapp" 这样的字母名称。
根据 docs:
Test Credentials
If you received this error while trying to authenticate with your Test Credentials, you probably tried to send a message with a From number from your live account. The only number that can be used to send successful messages with your Test Credentials is +15005550006. For more information, read our documentation on the From number for sending SMS with your test credentials.
因此您需要将 +15005550006
硬编码为 From
。
有关他们 API 的更多信息,请参阅 this