Last active
December 18, 2015 15:39
-
-
Save caseysoftware/5806101 to your computer and use it in GitHub Desktop.
Making an outbound call with PHP on Twilio
This file contains hidden or 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 | |
| // Include the Twilio PHP library | |
| require 'Services/Twilio.php'; | |
| // Set our Account SID and AuthToken | |
| $sid = 'AC123'; | |
| $token = 'abcd'; | |
| // A phone number you have previously validated with Twilio | |
| $phonenumber = '4151234567'; | |
| // Instantiate a new Twilio Rest Client | |
| $client = new Services_Twilio($sid, $token, $version); | |
| try { | |
| // Initiate a new outbound call | |
| $call = $client->account->calls->create( | |
| $phonenumber, // The number of the phone initiating the call | |
| '5101234567', // the number we are sending to - Any phone number | |
| 'http://demo.twilio.com/welcome/voice/' // The URL Twilio will request when the call is answered | |
| ); | |
| echo 'Started call: ' . $call->sid; | |
| } catch (Exception $e) { | |
| echo 'Error: ' . $e->getMessage(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment