我正在使用 Twilio 开发一个 IVR 应用程序并使用 [record] 标签对某人的姓名进行简短记录。
所以 page1.php 看起来像这样:
<?php
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<Response>
<Say>Please state your name after the tone</Say>
<Record maxLength="20" finishOnKey="#" playBeep="true" action="page2.php" />
</Response>
这很好,并且 RecordingURL 值按原样传递到 page2.php 中。但是,在 page2.php 上,我要求用户输入他们的参考号,并且需要将 RecordingURL 值传递给 page3.php。
Page2.php
<?php
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$rec_url=$_REQUEST['RecordingUrl'];
?>
<Response>
<Gather timeout="7" finishOnKey="#" numDigits="3" action="page3.php?rec_url=<?php echo $_REQUEST['RecordingUrl']; ?>" method="POST">
<Say>Please now enter your reference number</Say>
</Gather>
</Response>
Page3.php
<?php
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$ref_no=$_REQUEST['Digits'];
$cli=$_REQUEST['From'];
$rec_url=$_GET['rec_url'];
$nodialled=$_REQUEST['To'];
?>
<Response>
<Say>Thank you. Goodbye.</Say>
</Response>
<?php
$ref_no=$_POST['Digits'];
$cli=$_POST['From'];
$recording_url=$_POST['rec_url'];
$nodialled=$_POST['To'];
$html="<br />";
file_put_contents("test.html", "CLI: $cli $html Number Dialled: $nodialled $html Reference: $ref_no $html Recording URL: $recording_url");
?>
有任何想法吗?