我试图在 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>