Forward Twilio Account Phone Calls to Phone Number with Correct Caller ID
I wrote this script to go along with the sms forwarding script so if someone called or txt one of my old phone numbers it would get forwarded to my current mobile phone number. I have moved from a few different areas and each time I like to get a new local phone number so to keep my old phone numbers I port them to twilio and am able to forward calls and txt’s to my mobile phone.
The first step is to get a copy of the twilio php library at the following github page:
Once you have a copy of the library make sure to have the directory in your development environment. See below for the sample code to forward phone calls using the caller id number of the person calling. I keep the caller id number intact to show the person who is calling me which makes it easier to know who called.
case "+1407NXXXXXX": // your twilio #
$phone_number = "1941NXXXXXX"; // phone # to send call to
$phone_number = "1413NXXXXXX";
$response = new Services_Twilio_Twiml();
$response->dial($phone_number, array("callerId" => $_REQUEST['From']));
Once you host the script on a web server it just requires pointing the phone number in the twilio account settings as seen below.