Twilio 呼叫筛选 PHP

发布于 2024-11-26 22:50:33 字数 2760 浏览 4 评论 0 原文

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

attempts_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.phpcomplete_call.xml

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

<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say>Connecting</Say>
</Response>

我正在研究它 我认为他们网站上的错误是他们正在调用某些文件 .xml 并在代码中将其用作 .php 。

调试链接显示:

错误:HTTP 检索失败
组件:TwiML 错误 http响应:500 错误代码:11200 网址:http://test.com.testExample.com/Call/screen_for_machine.php

错误代码 11200 为:

错误 - 11200 HTTP 检索失败

尝试检索此 URL 的内容时失败 可能的原因

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

我的分析认为屏幕 php 文件有问题,因为它甚至没有向我读取 xml 说按任意键拾取。

错误已修复...问题出在

I tried to run the Call Screening example. When my other phone number received the call, the error message was read "Sorry an error has occurred, please check the debug link." After this error occurred I did not do anything and the call did not hang up. So I pressed a key on my keypad and it connected the call. The call screening app is suppose to call someone and ask if they want to take the call or not. That feature works but I am not sure why it read the error message. Furthermore, after I hung up on my phone receiving the call, the next number was getting a call which should not happen as the 1st phone number picked up the call.

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>

I am looking into it as we speak. I think the error on their site is that they are calling certain files .xml and using it as .php in their code.

Debug link says:

ERROR: HTTP retrieval failure
Component: TwiML errors
httpResponse: 500
ErrorCode: 11200
url: http://test.com.testExample.com/Call/screen_for_machine.php

The error code 11200 reads:

Error - 11200
HTTP retrieval failure

There was a failure attempting to retrieve the contents of this URL
Possible Causes

Web server returned a 4xx or 5xx HTTP response to Twilio
Misconfigured Web Server
Network disruptions between Twilio and your web server

Possible Solutions

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

My analysis goes that there is something wrong with the Screen php file as it does not even read to me the xml saying press any key to pick up..

The error is fixed...The problem was with the

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

绳情 2024-12-03 22:50:33

我们提供的示例中有一个错误。 行导致 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>

There's an error in the example we provide. The <?xml version="1.0" encoding="UTF-8"?> line causes issues with PHP, so it needs to be written out like this:

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>
你另情深 2024-12-03 22:50:33

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

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

这可能是我做的事情,但它让我困扰了很长时间。

If anyone else is having issues, I found that in the zip file I downloaded from Twilio, somehow there was a closing quote missing:

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

It might have been something I did, but it foxed me for ages.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文