Fetching contributors…
Cannot retrieve contributors at this time
50 lines (33 sloc) 1.22 KB

Twilio API helper library



pear channel-discover
pear install twilio/Services_Twilio

If you aren't using PEAR, you can just download the source


Getting started with the Twilio API couldn't be easier. Create a Twilio REST client to get started. For example, the following code makes a call using the Twilio REST API.

Making a Call

require "Services/Twilio.php";

$sid = "ACXXXXXX"; // Your Twilio account sid
$token = "YYYYYY"; // Your Twilio auth token

$client = new Services_Twilio($sid, $token);
$call = $client->account->calls->create(
    '9991231234', // From this number
    '8881231234', // Call this number

Generating TwiML

To control phone calls, your application need to output TwiML. Use Services_Twilio_Twiml to easily create such responses.

$response = new Services_Twilio_Twiml();
print $response;
<?xml version="1.0" encoding="utf-8"?>
<Response><Play loop="5">monkey.mp3</Play><Response>

Full Documentation