如何使用rest api保持Twilio呼叫暂停或暂停

时间:2017-05-30 11:28:51

标签: php twilio-php

我正在尝试从Twilio JS客户端实现Twilio呼叫保持功能,但呼叫会从用户端掉线/断开。

以下是我的代码:

$client = new Client($sid, $authtoken);
$call = $client->calls($callSid)->update(
            array(
                "Url"    => 'http://demo.com/Twiml/Hold.php",
                "method" => "POST"
            )
        );
        echo $call->to;

这是hold.php

<?php 
header("Content-type: text/xml");
echo "<?xml version='1.0' encoding='UTF-8'?>";
echo "<Response>
     <Enqueue waitUrl='wait-music.php'>support</Enqueue>
</Response>";
?>

这是wait-music.php文件

<?php
echo '<?xml version="1.0" encoding="UTF-8" ?>';
echo "<Response>";
echo "<Play>http://com.twilio.sounds.music.s3.amazonaws.com/MARKOVICHAMP-Borghestral.mp3</Play>";
echo "</Response>";
?>

并收到错误:

  

Twilio /休息/ Client.phpTwilio / HTTP / CurlClient.phpTwilio / HTTP / Client.phpTwilio /休息/ Api.phpTwilio / Domain.phpTwilio /休息/原料药/ V2010.phpTwilio / Version.phpTwilio /休息/原料药/ V2010 /AccountContext.phpTwilio/InstanceContext.phpTwilio/Rest/Api/V2010/Account/CallList.phpTwilio/ListResource.phpTwilio/Rest/Api/V2010/Account/CallContext.phpTwilio/Values.phpTwilio/VersionInfo.phpTwilio/Http/Response.phpTwilio /Exceptions/RestException.phpTwilio/Exceptions/TwilioException.php

**Fatal error:**  
  

带有消息的未捕获异常'Twilio \ Exceptions \ RestException'   '[HTTP 400]无法更新记录:未指定'到'号码   server_pathTwilio / Version.php:85       堆栈跟踪:       #0 server_path / Twilio / Version.php(127):Twilio \ Version-&gt;异常(对象(Twilio \ Http \ Response),'无法   updat ...')

0 个答案:

没有答案