Twilio呼叫屏蔽PHP

Twilio呼叫屏蔽PHP,php,twilio,phone-call,Php,Twilio,Phone Call,我尝试运行呼叫筛选示例。当我的另一个电话号码接到电话时,错误信息是“抱歉,发生了错误,请检查调试链接”。发生此错误后,我没有做任何事情,电话也没有挂断。所以我按下键盘上的一个键,它就接通了电话。呼叫筛选应用程序可以给某人打电话,询问他们是否愿意接听电话。该功能可以工作,但我不确定它为什么会读取错误消息。此外,在我挂断电话接电话后,下一个号码接到了一个电话,这不应该发生,因为第一个电话号码接了电话 尝试调用.php <?php // Set the numbers to call $nu

我尝试运行呼叫筛选示例。当我的另一个电话号码接到电话时,错误信息是“抱歉,发生了错误,请检查调试链接”。发生此错误后,我没有做任何事情,电话也没有挂断。所以我按下键盘上的一个键,它就接通了电话。呼叫筛选应用程序可以给某人打电话,询问他们是否愿意接听电话。该功能可以工作,但我不确定它为什么会读取错误消息。此外,在我挂断电话接电话后,下一个号码接到了一个电话,这不应该发生,因为第一个电话号码接了电话

尝试调用.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
}
?>
可能的解决办法

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,比如说按任意键拾取


错误已修复…问题在于我们提供的示例中存在错误。
行会导致出现问题,因此需要这样写:

为_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>
<?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>

按任意键接受此呼叫

如果其他人有问题,我发现在我从Twilio下载的zip文件中,不知何故缺少一个结束语:

<?php header("content-type: text/xml"); 
    echo '<?xml version="1.0" encoding="UTF-8"?>'; //The " after the 'UTF-8' was missing
?> 

此调试链接说明了什么?
<?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>
<?php header("content-type: text/xml"); 
    echo '<?xml version="1.0" encoding="UTF-8"?>'; //The " after the 'UTF-8' was missing
?>