dtnpf35197 2017-07-06 15:29
浏览 91

Twilio传出的浏览器呼叫断开连接

I'm using Twilio Outgoing Browser Calls in my project. The twiml to make call is like this :

<Response>
    <Dial action="hold_twiml.php" callerId="xxxxxxxxxx">
          xxxxxxxxxx
    </Dial>
</Response>

hold_twiml.php

if ( $_REQUEST['DialCallStatus'] == 'completed' ) { ?>
<Response>
    <Hangup/>
</Response>
<?php
}
else {
?>
<Response>
    <Play>http://demo.twilio.com/docs/classic.mp3</Play>
    <Redirect>hold_twiml.php</Redirect>
</Response>
<?php
}
?>

I want to disconnect the call when the call ends from client/browser. For that I've added the if ( $_REQUEST['DialCallStatus'] == 'completed' ) condition and now the call is getting ended from both sides. But now the Hold feature is not working properly. When I click the hold button the following code will be executed.

if ( $action == 'hold' ) {
 $url = "holding_twiml.php";
 $call = $client->calls->read(
        array("ParentCallSid" => $_POST['callSid'])
    )[0];
} else {  // unhold
 $call = $client->calls($_POST['callSid'])->fetch();
 $url = "redirecting_twiml.php";
}
$call->update(
    array(
        "url" => $url,
        "method" => "POST"
    )
);

holding_twiml.php

<Response>
    <Enqueue waitUrl="hold_music_twiml.xml">xx</Enqueue>
</Response>

hold_music_twiml.xml

<Response>
    <Play>http://demo.twilio.com/docs/classic.mp3</Play>
</Response>

redirecting_twiml.php

<Response>
  <Dial action="hold_twiml.php">
    <Queue>xx</Queue>
  </Dial>
</Response>

Now on clicking Hold, the call on browser is getting ended and the call over client(phone) is put into hold.

Can anyone help me to fix the issue? Thanks in advance.

  • 写回答

1条回答 默认 最新

  • doufeixuan8882 2017-07-06 15:46
    关注

    Twilio developer evangelist here.

    You are using an action attribute on the <Dial> TwiML. From the documentation:

    If you provide an 'action' URL, Twilio will continue the current call after the dialed party has hung up, using the TwiML received in your response to the 'action' URL request.

    So, when the client hangs up, Twilio is continuing the call using the TwiML received from your action URL.

    If you remove the action attribute or change the TwiML to <Hangup/> then your call will end when the client hangs up.

    Let me know if that helps at all.

    评论

报告相同问题?

悬赏问题

  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥15 绘制多分类任务的roc曲线时只画出了一类的roc,其它的auc显示为nan
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?