【问题标题】:Error while doing conferencing in Twilio在 Twilio 中进行会议时出错
【发布时间】:2015-03-04 13:47:09
【问题描述】:

我正在开发一个通过Twilio API 进行语音通话的应用程序 但在第一次通话后它会断开连接。

这是我的代码:

my index.php

<?php
$serverroot=$_SERVER['DOCUMENT_ROOT'].'/twilioapi/twilio-php-master/Services/Twilio.php';
require($serverroot); 
$version = "2010-04-01"; 
 $num= '+1 218-461-4418';
 $num1= '+91$$$$$$$$$$$';
 $num2= '+91$$$$$$$$$$$';
 $num3= '+91$$$$$$$$$$$';  

$account_sid = '$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'; 
$auth_token = '$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'; 
$client = new TwilioRestClient($account_sid, $auth_token); 

  $participants = array($num1, $num2, $num3);

  // Go through the participants array and call each person.
  foreach ($participants as $particpant)
  {
    $vars = array(
      'From' => $num,
      'To' => $participant,
      'Url' => 'http://my_url.com/twilioapi/mytest2.xml');

    echo $response = $client->request("/$version/Accounts/$account_sid/Calls", "GET", $vars);
  }

//echo json_encode($response);

?>

xml file

<Response>
    <Say>Joining a conference room</Say>
       <Dial>
         <Conference>MyRoom</Conference>
       </Dial>
</Response>

问候

【问题讨论】:

    标签: php android twilio conferencing


    【解决方案1】:

    这里是 Twilio 开发者宣传员。

    我不确定为什么您的代码会拨打一个电话然后断开连接。我可以告诉你一件事我会做不同的事情,这可能会有所帮助。

    而不是像您那样使用 TwilioRestClient 对象调用 API:

    // Set up $client
    $client = new TwilioRestClient($account_sid, $auth_token); 
    // Make request (using $vars from loop)
    $client->request("/$version/Accounts/$account_sid/Calls", "GET", $vars);
    

    您实际上可以要求 Services_Twilio 类并使用它使调用更容易:

    // set up $client
    $client = new Sevices_Twilio($account_sid, $auth_token);
    
    // set up participants then...
    
    foreach ($participants as $particpant) {
      echo $response = $client->account->calls->create(
        $num,          // The from number
        $participant,  // The to number
        'http://my_url.com/twilioapi/mytest2.xml'
      );
    

    }

    我想到的另一件事。调用 Calls 端点以创建调用应该是 POST 而不是 GET。也许这就是它失败的原因。不过,使用 Services_Twilio 对象应该会有所帮助。

    查看documentation on creating calls,如果您需要任何进一步的帮助,请告诉我。

    【讨论】:

    • 感谢您的想法....您的代码示例不起作用,但您对调用的想法确实......它就像一个魅力。 :-)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-06
    • 1970-01-01
    • 2014-01-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多