Skip to content

Instantly share code, notes, and snippets.

Last active Dec 23, 2015
What would you like to do?
sip forwarding with twilio
# sip.php
# quick and dirty outbound routing for sip phones with Twilio
# in your twilio sip tab
# set up your sip domain (
# register credentials for the username as the callback number with no spaces or +1 eg "3135551212" and set password
# validate the callback number
# set this script to the voice url
# set your sip client to authenticate with CALLBACKNUMBER/PASSWORD and host
# enjoy extremely convenient outbound SIP calling
<? print '<?xml version="1.0" encoding="UTF-8"?>' ?>
function sip2number($sip) { list($proto, $url, $port) = split(":", $sip);
list($number, $domain) = split("@", $url); return $number;
echo '<Dial callerId="+1' . sip2number($_REQUEST['From']) . '">' . sip2number($_REQUEST['To']) . '</Dial>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment