iffifan / twilio-php
A PHP wrapper for Twilio's API
Requires
- php: >=7.1.0
Requires (Dev)
- guzzlehttp/guzzle: ^6.3
- phpunit/phpunit: >=4.5
- theseer/phpdox: ^0.12.0
Suggests
- guzzlehttp/guzzle: An HTTP client to execute the API requests
- dev-legacy
- 6.0.1
- 6.0.0
- 5.42.2
- 5.42.1
- 5.42.0
- 5.41.1
- 5.41.0
- 5.40.0
- 5.39.0
- 5.38.0
- 5.37.0
- 5.36.1
- 5.36.0
- 5.35.0
- 5.34.4
- 5.34.3
- 5.34.2
- 5.34.1
- 5.34.0
- 5.33.0
- 5.32.1
- 5.32.0
- 5.31.3
- 5.31.2
- 5.31.1
- 5.31.0
- 5.30.2
- 5.30.1
- 5.30.0
- 5.29.1
- 5.29.0
- 5.28.1
- 5.28.0
- 5.27.1
- 5.27.0
- 5.26.0
- 5.25.0
- 5.24.2
- 5.24.1
- 5.24.0
- 5.23.1
- 5.23.0
- 5.22.0
- 5.21.4
- 5.21.3
- 5.21.2
- 5.21.1
- 5.21.0
- 5.20.0
- 5.19.7
- 5.19.6
- 5.19.5
- 5.19.4
- 5.19.3
- 5.19.2
- 5.19.1
- 5.19.0
- 5.18.0
- 5.17.1
- 5.17.0
- 5.16.7
- 5.16.6
- 5.16.5
- 5.16.4
- 5.16.3
- 5.16.2
- 5.16.1
- 5.16.0
- 5.15.6
- 5.15.5
- 5.15.4
- 5.15.3
- 5.15.2
- 5.15.1
- 5.15.0
- 5.14.1
- 5.14.0
- 5.13.4
- 5.13.3
- 5.13.2
- 5.13.1
- 5.13.0
- 5.12.1
- 5.12.1-alpha1
- 5.11.0
- 5.11.0-alpha1
- 5.10.0
- 5.10.0-alpha1
- 5.9.1
- 5.9.0
- 5.9.0-alpha1
- 5.8.0
- 5.8.0-alpha1
- 5.7.3
- 5.7.3-alpha1
- 5.7.2
- 5.7.2-alpha1
- 5.7.1
- 5.7.1-alpha2
- 5.7.1-alpha1
- 5.7.0
- 5.6.0
- 5.6.0-alpha1
- 5.5.0
- 5.5.0-alpha1
- 5.4.2
- 5.4.2-alpha1
- 5.4.1
- 5.4.1-alpha1
- 5.4.0
- 5.4.0-alpha1
- 5.3.0
- 5.3.0-alpha1
- 5.2.0
- 5.2.0-alpha1
- 5.1.1
- 5.1.1-alpha1
- 5.1.0
- 5.1.0-alpha2
- 5.1.0-alpha1
- 5.0.3
- 5.0.3-alpha1
- 5.0.2
- 5.0.2-alpha1
- 5.0.1
- 5.0.1-alpha1
- 5.0.0
- 5.0.0-RC22
- 5.0.0-RC21
- 5.0.0-RC20
- 5.0.0-RC19
- 5.0.0-RC18
- 5.0.0-RC17
- 5.0.0-RC16
- 5.0.0-RC15
- 5.0.0-RC14
- 5.0.0-RC13
- 5.0.0-RC12
- 5.0.0-RC11
- 5.0.0-RC10
- 5.0.0-RC9
- 5.0.0-RC8
- 5.0.0-RC7
- 5.0.0-RC6
- 5.0.0-RC5
- 5.0.0-RC4
- 5.0.0-RC3
- 5.0.0-RC2
- 5.0.0-RC1
- 4.12.1
- 4.12.0
- 4.11.0
- 4.10.0
- 4.9.3
- 4.9.2
- 4.9.1
- 4.9.0
- 4.8.1
- 4.8.0
- 4.7.0
- 4.6.1
- 4.6.0
- 4.5.0
- 4.4.0
- 4.3.0
- 4.2.1
- 4.2.0
- 4.1.0
- 4.0.4
- 4.0.3
- 4.0.2
- 4.0.1
- 4.0.0
- 3.13.1
- 3.13.0
- 3.12.8
- 3.12.7
- 3.12.6
- 3.12.5
- 3.12.4
- 3.12.3
- 3.12.2
- 3.12.1
- 3.12.0
- 3.10.0
- 3.9.1
- 3.9.0
- 3.8.3
- 3.8.2
- 3.8.1
- 3.8.0
- 3.7.2
- 3.7.1
- 3.7.0
- 3.6.0
- 3.5.2
- 3.5.1
- 3.5.0
- dev-master
- dev-travis
This package is auto-updated.
Last update: 2025-01-07 00:47:28 UTC
README
Installation
You can install twilio-php via composer or by downloading the source.
Via Composer:
twilio-php is available on Packagist as the
twilio/sdk
package.
Via ZIP file:
Click here to download the source (.zip) which includes all dependencies.
Once you download the library, move the twilio-php folder to your project directory and then include the library file:
require '/path/to/twilio-php/Services/Twilio.php';
and you're good to go!
A Brief Introduction
With the twilio-php library, we've simplified interaction with the Twilio REST API. No need to manually create URLS or parse XML/JSON. You now interact with resources directly. Follow the Quickstart Guide to get up and running right now. The User Guide shows you how to get the most out of twilio-php.
Quickstart
Send an SMS
<?php // Install the library via PEAR or download the .zip file to your project folder. // This line loads the library require('/path/to/twilio-php/Services/Twilio.php'); $sid = "ACXXXXXX"; // Your Account SID from www.twilio.com/user/account $token = "YYYYYY"; // Your Auth Token from www.twilio.com/user/account $client = new Services_Twilio($sid, $token); $message = $client->account->messages->sendMessage( '9991231234', // From a valid Twilio number '8881231234', // Text this number "Hello monkey!" ); print $message->sid;
Make a Call
<?php // Install the library via PEAR or download the .zip file to your project folder. // This line loads the library require('/path/to/twilio-php/Services/Twilio.php'); $sid = "ACXXXXXX"; // Your Account SID from www.twilio.com/user/account $token = "YYYYYY"; // Your Auth Token from www.twilio.com/user/account $client = new Services_Twilio($sid, $token); $call = $client->account->calls->create( '9991231234', // From a valid Twilio number '8881231234', // Call this number // Read TwiML at this URL when a call connects (hold music) 'http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient' );
Generating TwiML
To control phone calls, your application needs to output
TwiML. Use
Services_Twilio_Twiml
to easily create such responses.
<?php require('/path/to/twilio-php/Services/Twilio.php'); $response = new Services_Twilio_Twiml(); $response->say('Hello'); $response->play('https://api.twilio.com/cowbell.mp3', array("loop" => 5)); print $response;
That will output XML that looks like this:
<?xml version="1.0" encoding="utf-8"?> <Response> <Say>Hello</Say> <Play loop="5">https://api.twilio.com/cowbell.mp3</Play> <Response>
Full Documentation
The documentation for twilio-php is hosted at Read the Docs. Click here to read our full documentation.
Prerequisites
- PHP >= 5.2.3
- The PHP JSON extension
Getting help
If you need help installing or using the library, please contact Twilio Support at help@twilio.com first. Twilio's Support staff are well-versed in all of the Twilio Helper Libraries, and usually reply within 24 hours.
If you've instead found a bug in the library or would like new features added, go ahead and open issues or pull requests against this repo!