我尝试运行Call Screening示例。当我的其他电话号码接到电话时,错误消息显示为“抱歉发生错误,请检查调试链接”。发生此错误后,我没有做任何事情,电话没有挂断。所以我按下键盘上的一个键,然后连接了通话。呼叫筛选应用程序假设打电话给某人并询问他们是否要接听电话。该功能有效,但我不确定为什么它会读取错误消息。此外,在我挂断电话接听电话后,下一个号码正在接听电话,这不应该发生,因为第一个电话号码接听电话。
attempt_call.php
<?php
// Set the numbers to call
$numbers = array("<number to call 1>", "<number to call 2>", "<number to call n>");
$number_index = isset($_REQUEST['number_index']) ? $_REQUEST['number_index'] : "0";
$DialCallStatus = isset($_REQUEST['DialCallStatus']) ? $_REQUEST['DialCallStatus'] : "";
header("content-type: text/xml");
// Check the status of the call and
// that there is a valid number to call
if($DialCallStatus!="completed" && $number_index<count($numbers)){
?>
<Response>
<Dial action="attempt_call.php?number_index=<?php echo $number_index+1 ?>">
<Number url="screen_for_machine.php">
<?php echo $numbers[$number_index] ?>
</Number>
</Dial>
</Response>
<?php
} else {
?>
<Response>
<Hangup/>
</Response>
<?php
}
?>
screen_for_machine.php
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Gather action="complete_call.xml">
<Say>Press any key to accept this call</Say>
</Gather>
<Hangup/>
</Response>
complete_call.xml
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say>Connecting</Say>
</Response>
我在说话的时候正在研究它。我认为他们网站上的错误是他们正在调用某些文件.xml并在其代码中将其用作.php。
调试链接说:
错误:HTTP检索失败
组件:TwiML错误
httpResponse:500
ErrorCode:11200
网址:http://test.com.testExample.com/Call/screen_for_machine.php
错误代码11200显示为:
错误 - 11200 HTTP检索失败
尝试检索此网址的内容时失败 可能的原因
Web server returned a 4xx or 5xx HTTP response to Twilio
Misconfigured Web Server
Network disruptions between Twilio and your web server
可能的解决方案
Doublecheck that your TwiML URL does not return a 4xx or 5xx error
Make certain that the URL does not perform a 302 redirect to an invalid URL
Confirm the URL requested is not protected by HTTP Auth
Make sure your webserver allows HTTP POST requests to static resources (if the url referes to .xml or .html files)
Verify your web server is up and responsive
Check to see that the URL host is not a private or local IP address
Verify the ping times and packet loss between your web server and www.twilio.com
我的分析认为Screen php文件有问题,因为它甚至没有读到我的xml说按任意键拿起..
错误已修复......问题在于
答案 0 :(得分:2)
我们提供的示例中存在错误。 <?xml version="1.0" encoding="UTF-8"?>
行会导致PHP出现问题,因此需要将其写为:
screen_for_machine.php
<?php header("content-type: text/xml");
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<Response>
<Gather action="complete_call.xml">
<Say>Press any key to accept this call</Say>
</Gather>
<Hangup/>
</Response>
答案 1 :(得分:0)
如果有其他人遇到问题,我发现在我从Twilio下载的zip文件中,不知何故有一个关闭引用缺失:
<?php header("content-type: text/xml");
echo '<?xml version="1.0" encoding="UTF-8"?>'; //The " after the 'UTF-8' was missing
?>
这可能是我做过的事情,但它让我感到厌烦。