在Twilio中创建出站电话会议时出错

时间:2017-10-17 13:57:42

标签: twilio twilio-api twilio-php

我试图从Twilio会议中拨打电话有点困难。

到目前为止,我尝试了两种不同的方法:使用PHP并使用curl对API进行POST调用。

当我使用curl时,我会执行以下操作:

curl "https://api.twilio.com/2010-04-01/Accounts/<my_account_sid/Conferences/<conference_sid>/Participants" -X POST --data-urlencode 'To=<destination_number>' --data-urlencode 'From=<source_number>' --data-urlencode 'EarlyMedia=true' -u [my_account_sid]:[token]

以下是我从API获得的回复:

<?xml version='1.0' encoding='UTF-8'?>
<TwilioResponse><RestException><Code>20006</Code><Message>Access Denied</Message><MoreInfo>https://www.twilio.com/docs/errors/20006</MoreInfo><Status>403</Status></RestException></TwilioResponse>

我一直在使用主帐户的凭据,我可以使用它们用curl做其他GET,所以我知道系统实际上是在验证我。

当我使用PHP(最新的库)时,我尝试运行这个脚本:

<?php
    require __DIR__ . '/vendor/autoload.php';
    use Twilio\Rest\Client;
    $ACCOUNT_SID = '<my_account_sid>';
    $AUTH_TOKEN = '<token>';

    $client = new Client($ACCOUNT_SID, $AUTH_TOKEN);
    $participant = $client
        ->conferences("<friendly_name>")
        ->participants
        ->create([
           'from' => '<source_number>',
           'to' => '<destination_number>'
        ]);
?>

我从这个脚本得到的输出是:

PHP Warning:  Missing argument 2 for Twilio\Rest\Api\V2010\Account   \Conference\ParticipantList::create(), called in /var/www/html/voice/conference.php on line 15 and defined in /var/www/html/voice/vendor/twilio/sdk/Twilio/Rest/Api/V2010/Account/Conference/ParticipantList.php on line 48
PHP Notice:  Undefined variable: to in /var/www/html/voice/vendor/twilio/sdk/Twilio/Rest/Api/V2010/Account/Conference/ParticipantList.php on line 53
PHP Fatal error:  Uncaught exception 'Twilio\Exceptions\RestException' with message '[HTTP 400] Unable to create record: Failed to validate conference attributes' in /var/www/html/voice/vendor/twilio/sdk/Twilio/Version.php:85`
Stack trace:
#0 /var/www/html/voice/vendor/twilio/sdk/Twilio/Version.php(207): Twilio\Version->exception(Object(Twilio\Http\Response), 'Unable to creat...')
#1 /var/www/html/voice/vendor/twilio/sdk/Twilio/Rest/Api/V2010/Account/Conference/ParticipantList.php(87): Twilio\Version->create('POST', '/Accounts/AC893...', Array, Array)
#2 /var/www/html/voice/conference.php(15): Twilio\Rest\Api\V2010\Account\Conference\ParticipantList->create(Array)
#3 {main}
thrown in /var/www/html/voice/vendor/twilio/sdk/Twilio/Version.php on line 85

请有人帮我这个吗?

非常感谢,

的Fabrizio

1 个答案:

答案 0 :(得分:1)

对于子孙后代,问题是我没有在我的门户网站上启用代理商会议。 请参阅https://www.twilio.com/console/voice/settings/conferences