Created
January 5, 2015 03:36
-
-
Save lg/ba26bba8219af9da5e1d to your computer and use it in GitHub Desktop.
TwiML for a long distance phone dialer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$my_url = 'http://MYDOMAIN.COM/twilio_ld/twilio_ld.php'; | |
echo '<?xml version="1.0" encoding="UTF-8"?>'; | |
echo '<Response>'; | |
if (array_key_exists('passcode_check', $_GET)) { | |
if ($_POST["Digits"] == '1') { | |
echo '<Gather timeout="5" finishOnKey="*" action="' . $my_url . '?dial">'; | |
echo '<Say>OK. Type the number.</Say>'; | |
echo '</Gather>'; | |
} else { | |
// This person doesn't know to press 1. Probably an autodialer. | |
echo '<Hangup/>'; | |
} | |
} else if (array_key_exists('dial', $_GET)) { | |
echo '<Say>Alright! Calling the number!</Say>'; | |
echo '<Dial callerId="+16131112222" action="' . $my_url . '?call_complete">'; | |
echo ' <Sip username="VOICETRADINGUSERNAME" password="VOICETRADINGPASSWORD">'; | |
echo ' sip:00000' . $_POST["Digits"] . '@sip.voicetrading.com'; | |
echo ' </Sip>'; | |
echo '</Dial>'; | |
} else if (array_key_exists('call_complete', $_GET)) { | |
if ($_POST["DialCallStatus"] == "busy") { | |
echo '<Say>Sorry, couldn\'t connect. The line was busy.</Say>'; | |
} else if ($_POST["DialCallStatus"] == "no-answer") { | |
echo '<Say>Sorry, couldn\'t connect. Nobody answered.</Say>'; | |
} else if ($_POST["DialCallStatus"] == "failed") { | |
echo '<Say>Sorry, there was a problem connecting. Check the phone number.</Say>'; | |
} | |
echo '<Pause length="1"/>'; | |
echo '<Hangup/>'; | |
} else { | |
echo '<Gather timeout="5" finishOnKey="*" action="' . $my_url . '?passcode_check">'; | |
echo '<Pause length="1"/>'; | |
echo '<Say>Hello!</Say>'; | |
echo '</Gather>'; | |
} | |
echo '</Response>'; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment