I attempted to add a new digit to the Twilio.com hello monkey script. When I press 1, 2 or 0 it restarts, it doesn't navigate to the voicemail or direct the call.
Here's my code:
Step 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>
Step 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>
Use a full URL for the action:
<Gather numDigits="1" action="handle.php" method="POST">
It seems that using a full URL in the play tag is causing Twilio to treat handle.php as http://morxmedia.com/phone/handle.php (which, at this moment, does not exist).
When I ran your sample code, I got an application error (because handle.php did not exist). My guess is that you have the 'fallback' URL set to the main menu, and that's what's causing the confusion.
Update: It should be noted that only using http://morxmedia.com/phone/tech-support.mp3 causes the odd reset of relative paths, using the hello monkey mp3 file does not. Perhaps some odd server configuration is confusing the Twilio HTTP client (causing the path issue, and the continued requesting of step1.php).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With