Skip to content

Instantly share code, notes, and snippets.

@caseysoftware
Last active December 18, 2015 15:39
Show Gist options
  • Select an option

  • Save caseysoftware/5806101 to your computer and use it in GitHub Desktop.

Select an option

Save caseysoftware/5806101 to your computer and use it in GitHub Desktop.
Making an outbound call with PHP on Twilio
<?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