Code Monkey home page Code Monkey logo

twilio-php's Introduction

twilio-php

Build Status Packagist Packagist

Recent Update

As of release 5.13.0, Beta and Developer Preview products are now exposed via the main twilio-php artifact. Releases of the alpha branch have been discontinued.

If you were using the alpha release line, you should be able to switch back to the normal release line without issue.

If you were using the normal release line, you should now see several new product lines that were historically hidden from you due to their Beta or Developer Preview status. Such products are explicitly documented as Beta/Developer Preview both in the Twilio docs and console, as well as through in-line code documentation here in the library.

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.

Quickstart

Send an SMS

// Send an SMS using Twilio's REST API and PHP
<?php
$sid = "ACXXXXXX"; // Your Account SID from www.twilio.com/console
$token = "YYYYYY"; // Your Auth Token from www.twilio.com/console

$client = new Twilio\Rest\Client($sid, $token);
$message = $client->messages->create(
  '8881231234', // Text this number
  array(
    'from' => '9991231234', // From a valid Twilio number
    'body' => 'Hello from Twilio!'
  )
);

print $message->sid;

Make a Call

<?php
$sid = "ACXXXXXX"; // Your Account SID from www.twilio.com/console
$token = "YYYYYY"; // Your Auth Token from www.twilio.com/console

$client = new Twilio\Rest\Client($sid, $token);

// Read TwiML at this URL when a call connects (hold music)
$call = $client->calls->create(
  '8881231234', // Call this number
  '9991231234', // From a valid Twilio number
  array(
      'url' => 'https://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient'
  )
);

Generating TwiML

To control phone calls, your application needs to output TwiML. Use Twilio\Twiml to easily create such responses.

<?php
$response = new 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>

Documentation

The documentation for the Twilio API is located here.

The PHP library documentation can be found here.

Versions

twilio-php's versioning strategy can be found here.

Prerequisites

  • PHP >= 5.5
  • The PHP JSON extension

Docker Image

The Dockerfile present in this repository and its respective twilio/twilio-php Docker image are currently used by Twilio for testing purposes only.

Getting help

If you need help installing or using the library, please contact Twilio Support at [email protected] 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!

twilio-php's People

Contributors

kyleconroy avatar codejudas avatar jwitz10 avatar skimbrel avatar dougblack avatar luciferous avatar kevinburke avatar ihumanable avatar twilio-ci avatar alexpayment avatar jmctwilio avatar jingming avatar caseysoftware avatar gipetto avatar sjlangley avatar ilanbiala avatar alexcchan avatar wanjunsli avatar carlosdp avatar ekarson avatar till avatar cjcodes avatar dataich avatar ragil avatar plabbett avatar seldaek avatar jarodreyes avatar chrisbarr avatar vassjozsef avatar tacman avatar

Watchers

Joshua Gigg avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.