使用 PHP54 和 Twilio 发送消息时出现 Http 500 错误 [英] Http 500 Error Sending a Message using PHP54 and Twilio

查看:31
本文介绍了使用 PHP54 和 Twilio 发送消息时出现 Http 500 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    <?php
    // Require the bundled autoload file - the path may need to change
    // based on where you downloaded and unzipped the SDK
    require_once __DIR__ . '/twilio-php-master/Twilio/autoload.php';

    #require __DIR__ . '/var/sip10/public_html/htdocs/twilio/twilio-php-master/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 = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXX';
   $token = 'XXXXXXXXXXXXXXXXXXXXXXX';
   $client = new Client($sid, $token);


   // Use the client to do fun stuff like send text messages!

   $client->messages->create(
'+1XXXXXXXXXX',
array(
    'from' => '+1XXXXXXXXXX',
    'body' => "Hey Jenny! Good luck on the bar exam!"
)
);

?>

当我尝试向我的手机发送消息时,当所有正确的帐户信息都显示 http500 错误时,我测试了库是否正常工作(是的),我知道它因为 $client->messages- 而搞砸了>创建但不明白为什么.

When I try to Send a message to my phone when all the correct account information it says http500 error I tested if the library is working (yes it is) and I know it messes up because of the $client->messages->create but cannot understand why.

推荐答案

Twilio PHP 库依赖 cURL 来发出 HTTP 请求,这些请求实际上是命中 Twilio 的 API 端点以发送您的消息.

The Twilio PHP library relies on cURL to make the HTTP requests that are actually hitting the Twilio's API endpoints to send your message.

您需要使 PHP 可以使用 cURL.

You need to make cURL available to your PHP.

  • 输入 sudo apt-get install curl 安装 cURL
  • 输入 sudo service apache2 restart 来重启 Apache
  • 输入 sudo apt-get install php5-curl 安装 PHP5 cURL
  • 输入 sudo service apache2 restart
  • 重启 Apache
  • Install cURL by typing sudo apt-get install curl
  • Restart Apache by typing sudo service apache2 restart
  • Install PHP5 cURL by typing sudo apt-get install php5-curl
  • Restart Apache by typing sudo service apache2 restart

根据您的情况随意调整以上内容,但主要思想是 PHP 和 Twilio 库是不够的,您还需要 cURL.

Feel free to adjust the above for your case, but the main idea is PHP and Twilio library is not enough, you also need cURL.

这篇关于使用 PHP54 和 Twilio 发送消息时出现 Http 500 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆