首页 > 解决方案 > 通过 twilio 和 php 进行语音通话:autoload.php 中的解析错误

问题描述

我想使用 twilio php 库进行语音通话。我从twilio网站上提到的Github链接下载了 php 帮助程序库。然后我也使用了那里提供的 php 代码:

    <?php
// Include the bundled autoload from the Twilio PHP Helper Library
require __DIR__ . '/twilio-php-main/src/Twilio/autoload.php';
use Twilio\Rest\Client;

// Your Account SID and Auth Token from twilio.com/console
$account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$auth_token = 'your_auth_token';
// In production, these should be environment variables. E.g.:
// $auth_token = $_ENV["TWILIO_ACCOUNT_SID"]

// A Twilio number you own with Voice capabilities
$twilio_number = "+15017122661";

// Where to make a voice call (your cell phone?)
$to_number = "+15558675310";

$client = new Client($account_sid, $auth_token);
$client->account->calls->create(
    $to_number,
    $twilio_number,
    array(
        "url" => "http://demo.twilio.com/docs/voice.xml"
    )
);

不幸的是,我收到了错误

解析错误:语法错误,意外 ':',期待 ';' 或 '{' 在 /users/USER/www/twilio/twilio-php-main/src/Twilio/autoload.php 第 61 行。

我认为他们不可能是图书馆中的错误,并且自己无法找到或解决它。有人有想法吗?

标签: phptwiliotwilio-api

解决方案


推荐阅读