Skip to content

Instantly share code, notes, and snippets.

@oostendo
Last active December 23, 2015 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oostendo/6627956 to your computer and use it in GitHub Desktop.
Save oostendo/6627956 to your computer and use it in GitHub Desktop.
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 (DOMAIN.sip.twilio.com)
# 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 DOMAIN.sip.twilio.com
# enjoy extremely convenient outbound SIP calling
#
<? print '<?xml version="1.0" encoding="UTF-8"?>' ?>
<Response>
<?php
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>';
?>
</Response>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment