Twilio “需要”;简单菜单“;Twimlet制导

Twilio “需要”;简单菜单“;Twimlet制导,twilio,Twilio,我正在尝试使用Twimlet创建一个简单的警报系统,但我要么误解了Twimlet菜单的工作方式,要么是存在错误 以下是“What is Simple Menu”(什么是简单菜单)页面中的“示例1”: 返回以下TwiML: <Response> <Gather numDigits="1"> <Say>Hi There</Say> </Gather> <Redirect/> </Respon

我正在尝试使用Twimlet创建一个简单的警报系统,但我要么误解了Twimlet菜单的工作方式,要么是存在错误

以下是“What is Simple Menu”(什么是简单菜单)页面中的“示例1”:

返回以下TwiML:

<Response>
   <Gather numDigits="1">
      <Say>Hi There</Say>
   </Gather>
   <Redirect/>
</Response>

你好
让我困惑的是TwiML中根本没有对“”URL的引用


我是做错了什么,还是没抓住重点?

我不认为你做错了什么。 基本上将要发生的事情是,因为没有输入您可以看到的位置,当用户按下一个数字时,结果将是回调当前文档的url

如果您在这里查看菜单实现的源代码片段

// if DialStatus was sent, it means we got here after a Dial attempt
if (strlen($_REQUEST['Digits'])) 
{
    // if valid option given, the redirect
    if (strlen($location = $_REQUEST['Options'][$_REQUEST['Digits']])) 
    {
    header('Location: ' . $location);
    die;
} 
else 
{
    // answered call, so just hangup
    $response->say("I'm sorry, that wasn't a valid option.");
}
您将看到,他们正在检查是否存在数字,如果存在,则提取位置,然后重定向到该位置

关键的部分是理解Twilio聚集动词是如何工作的,你可以在这里找到更好的解释

// if DialStatus was sent, it means we got here after a Dial attempt
if (strlen($_REQUEST['Digits'])) 
{
    // if valid option given, the redirect
    if (strlen($location = $_REQUEST['Options'][$_REQUEST['Digits']])) 
    {
    header('Location: ' . $location);
    die;
} 
else 
{
    // answered call, so just hangup
    $response->say("I'm sorry, that wasn't a valid option.");
}

我希望这能有所帮助

谢谢你回答这个老生常谈的问题。这仍然是非常相关的,所以我很高兴终于有了一个答案!很高兴路易斯,很高兴我能帮忙