【问题标题】:Twilio Sms not sending PhpTwilio Sms 不发送 Php
【发布时间】:2019-05-09 04:56:12
【问题描述】:

我正在尝试使用 twilio 发送短信,但没有收到任何回复或无法发送短信 我正在使用以下代码,我错在哪里?

require __DIR__ . 'Twilio/autoload.php';
use Twilio\Rest\Client;
$sid    = "xxxxxxxxxxxxxxxxxx";
$token  = "xxxxxxxxxxxxxxxxxxx";
$twilio = new Client($sid, $token);

$message = $twilio->messages
                  ->create("+91xxxxxxx", // to verified twilio number
                           array(
                               "body" => "This is the ship that made the Kessel Run in fourteen parsecs?",
                               "from" => "+xxxxxxx"
                           )
                  );
print($message->sid);

【问题讨论】:

  • Twilio 调试日志中是否有任何消息?
  • 您使用的是沙盒还是实时详细信息?
  • @Gulshan:我正在使用沙箱详细信息并向已验证号码发送短信
  • @Hoppeduppeanut:不,调试日志中没有任何显示
  • 如果你var_dump($message),它会返回什么?

标签: php twilio twilio-api


【解决方案1】:

在这种情况下可能有以下原因。

  1. 确保您已启用 CURL 模块
  2. var_dump($message);
  3. 尝试打印 Twilio 对象 $twilio 以确保正确加载库。
  4. 通过添加脚本顶部打开php错误

    error_reporting(E_ALL);

    ini_set('display_errors','1');

【讨论】:

  • 现在我收到以下错误来自电话号码 +786xxxxx 无效,
  • @nehakhurana 你必须使用这种电话号码格式(+)(国家代码)(电话号码)
  • @nehakhurana 你有什么收获吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-18
  • 1970-01-01
  • 1970-01-01
  • 2017-12-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多