Last active
August 29, 2015 13:56
-
-
Save emilstahl/9179559 to your computer and use it in GitHub Desktop.
Make a call with PHP and the Twilio REST API.
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 | |
// Include Twilio PHP library | |
require 'Services/Twilio.php'; | |
// Twilio REST API version | |
$version = "2010-04-01"; | |
// AccountSid and AuthToken | |
$sid = 'AC4a5463a2b9db0755e9c668b8b117fb91'; | |
$token = 'f86d4aa9e8c17cafa80cd88de7594716'; | |
// Twilio or validated phone number | |
$phonenumber = '+4589880188'; | |
// Make outbound call | |
$client = new Services_Twilio($sid, $token, $version); | |
try { | |
// Initiate a new outbound call | |
$call = $client->account->calls->create( | |
$phonenumber, // Phone number making the call | |
'+4522162700', // Phone number receiving the call | |
'http://twimlbin.com/dd1c2f78' // URL Twilio will request if call is answered | |
); | |
echo 'Started call with Call SID: ' . $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