【发布时间】:2016-11-08 20:54:08
【问题描述】:
感谢您花时间阅读我的帖子。我试图设置一个IVR 来测试我的一个客户帐户,处理工作时间以外的来电等。我是 Twilio 和 PHP 的新手。
这是 XML 代码,它似乎运行正常:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Gather action="handle-user-input.php" numDigits="1">
<Say voice="woman">Welcome to COMPANY.</Say>
<Say voice="woman">In order to further assist you. Please listen to the following:</Say>
<Say voice="woman">For an option, please press 1.</Say>
<Say voice="woman">For a different option, please press 2.</Say>
<Say voice="woman">To speak with another person, please press 3.</Say>
<Say voice="woman">For all other inquiries, please press 4.</Say>
</Gather>
<!-- If they didnt put an input say this then retry -->
<Say voice="woman">Sorry, I didn't get your response.</Say>
<Redirect>http://www.exampleforstackoverflow.com/handle-incoming-call.xml</Redirect>
</Response>
因此,如果您要调用指向此 xml 文件的 twilio 号码,语音选项会播放并且它似乎可以正常工作。如果你按下一个输入 - 你会得到一个应用程序错误。 php文件handle-user-input.php如下:
<?php
$dayofweek=date('D');
$hour=date('H');
if(($dayofweek!='Sat')&&($dayofweek!='Sun')){
if(($hour>17)&&($hour<23)){
//ok time to call
$ok='1';
}
}
header('Content-type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<Response>';
$user_pushed = (int) $_REQUEST['Digits'];
if ($user_pushed == 1) {
echo '<Say voice="woman">Connecting you to, sales.</Say>';
if($ok!='1'){
echo '<Redirect>http://twimlets.com/voicemail?Email=info@example.com&Message=http://www.example.com/ftZLg.mp3</Redirect>';
} else {
echo '<Dial>+12345678901</Dial>';
}
} else if ($user_pushed == 2) {
echo '<Say voice="woman">Connecting you to some person.</Say>';
if($ok!='1') {
echo '<Redirect>http://twimlets.com/voicemail?Email=info@example.com&Message=http://www.example.com/ftZLg.mp3</Redirect>';
} else {
echo '<Dial>+12345678901</Dial>';
}
} else if ($user_pushed == 3) {
echo '<Say voice="woman">Connecting you to a person.</Say>';
if($ok!='1') {
echo '<Redirect>http://twimlets.com/voicemail?Email=info@example.com&Message=http://www.example.com/ftZLg.mp3</Redirect>';
} else {
echo '<Dial>+12345678901</Dial>';
}
} else if ($user_pushed == 4) {
echo '<Say voice="woman">Connecting you to, operator.</Say>';
if($ok!='1') {
echo '<Redirect>http://twimlets.com/voicemail?Email=info@example.com&Message=http://www.example.com/ftZLg.mp3</Redirect>';
} else {
echo '<Dial>+12345678901</Dial>';
}
} else {
echo "<Say voice="woman">Sorry, You dialed an invalid number.</Say>";
echo '<Redirect>http://www.exampleforstackoverflow.com/handle-incoming-call.xml</Redirect>';
}
echo '</Response>';
?>
我不确定我的 php 文件中是否有错误,也许有。但是,我注意到在我的 Twilio 错误日志中,我发现访问文件的请求超时。换句话说,http://example.com/handle-user-input.php 在 Twilio 尝试访问它时给出了错误 500。
无论如何,感谢您花时间阅读我的帖子。如果有人对我的错误有所了解,那就太棒了!
【问题讨论】: