3

我试图在 Twilio.com hello monkey 脚本中添加一个新数字。当我按 1、2 或 0 时,它会重新启动,它不会导航到语音信箱或直接呼叫。

这是我的代码:

第1步

<?php
// now greet the caller
    header("content-type: text/xml");
    echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<Response>   
    <Gather numDigits="1" action="handle.php" method="POST">
        <Play>http://morxmedia.com/phone/main.mp3</Play>
    </Gather>
</Response>

第2步

<?php

    // if the caller pressed anything but 1 or 2 send them back
    if($_REQUEST['Digits'] != '1' and $_REQUEST['Digits'] != '2' and $_REQUEST['Digits'] != '0') {
        header("Location: step1.php");
        die;
    }

    // otherwise, if 1 was pressed we Dial 3105551212. If 2 
    // we make an audio recording up to 30 seconds long.
    header("content-type: text/xml");
    echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<Response>
<?php if ($_REQUEST['Digits'] == '1') { ?>
    <Dial>+13105551212</Dial>
    <Say>The call failed or the remote party hung up.  Goodbye.</Say>
<?php } elseif ($_REQUEST['Digits'] == '2') { ?>
    <Play>http://morxmedia.com/phone/tech-support.mp3</Play>
    <Record maxLength="30" action="aftervm.php" />
<?php } elseif ($_REQUEST['Digits'] == '0') { ?>
    <Dial>+13105551212</Dial>
    <Say>The call failed or the remote party hung up.  Goodbye.</Say>
<?php } ?>
</Response>
4

1 回答 1

3

为操作使用完整的 URL:

<Gather numDigits="1" action="handle.php" method="POST">

似乎在播放标签中使用完整的 URL 导致 Twilio 被handle.php视为http://morxmedia.com/phone/handle.php(目前不存在)。

当我运行您的示例代码时,我收到了一个应用程序错误(因为handle.php不存在)。我的猜测是您将“后备”URL 设置为主菜单,这就是造成混乱的原因。

更新:需要注意的是,仅使用http://morxmedia.com/phone/tech-support.mp3会导致相对路径的奇数重置,使用 hello monkey mp3 文件不会。也许一些奇怪的服务器配置会混淆 Twilio HTTP 客户端(导致路径问题,以及对 的持续请求step1.php)。

于 2011-10-11T13:29:34.977 回答