Code Monkey home page Code Monkey logo

twilio-php's Introduction

twilio-php

Tests Quality Gate Status Packagist Packagist Learn with TwilioQuest

Documentation

The documentation for the Twilio API can be found here.

The PHP library documentation can be found here.

Versions

twilio-php uses a modified version of Semantic Versioning for all changes. See this document for details.

Supported PHP Versions

This library supports the following PHP implementations:

  • PHP 7.2
  • PHP 7.3
  • PHP 7.4
  • PHP 8.0
  • PHP 8.1
  • PHP 8.2
  • PHP 8.3

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:

composer require twilio/sdk

Test your installation

Here is an example of using the SDK to send a text message:

// Send an SMS using Twilio's REST API and PHP
<?php
// Required if your environment does not handle autoloading
require __DIR__ . '/vendor/autoload.php';

// Your Account SID and Auth Token from console.twilio.com
$sid = "ACXXXXXX";
$token = "YYYYYY";
$client = new Twilio\Rest\Client($sid, $token);

// Use the Client to make requests to the Twilio REST API
$client->messages->create(
    // The number you'd like to send the message to
    '+15558675309',
    [
        // A Twilio phone number you purchased at https://console.twilio.com
        'from' => '+15017250604',
        // The body of the text message you'd like to send
        'body' => "Hey Jenny! Good luck on the bar exam!"
    ]
);

Without Composer

While we recommend using a package manager to track the dependencies in your application, it is possible to download and use the PHP SDK manually. You can download the full source of the PHP SDK from GitHub, and browse the repo if you would like. To use the SDK in your application, unzip the SDK download file in the same directory as your PHP code. In your code, you can then require the autoload file bundled with the SDK.

<?php
// Require the bundled autoload file - the path may need to change
// based on where you downloaded and unzipped the SDK
require __DIR__ . '/twilio-php-main/src/Twilio/autoload.php';

// Your Account SID and Auth Token from console.twilio.com
$sid = "ACXXXXXX";
$token = "YYYYYY";
$client = new Twilio\Rest\Client($sid, $token);

// Use the Client to make requests to the Twilio REST API
$client->messages->create(
    // The number you'd like to send the message to
    '+15558675309',
    [
        // A Twilio phone number you purchased at https://console.twilio.com
        'from' => '+15017250604',
        // The body of the text message you'd like to send
        'body' => "Hey Jenny! Good luck on the bar exam!"
    ]
);

Usage

Make a Call

<?php
$sid = "ACXXXXXX";
$token = "YYYYYY";

$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
    [
        'url' => 'https://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient'
    ]
);

Warning It's okay to hardcode your credentials when testing locally, but you should use environment variables to keep them secret before committing any code or deploying to production. Check out How to Set Environment Variables for more information.

Get an existing Call

<?php
require_once '/path/to/vendor/autoload.php';

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

// Get an object using its SID. If you do not have a SID,
// check out the list resource examples on this page
$call = $client->calls("CA42ed11f93dc08b952027ffbc406d0868")->fetch();
print $call->to;

Iterate through records

The library automatically handles paging for you. Collections, such as calls and messages, have read and stream methods that page under the hood. With both read and stream, you can specify the number of records you want to receive (limit) and the maximum size you want each page fetch to be (pageSize). The library will then handle the task for you.

read eagerly fetches all records and returns them as a list, whereas stream returns an iterator and lazily retrieves pages of records as you iterate over the collection. You can also page manually using the page method.

<?php
require_once '/path/to/vendor/autoload.php';

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

$limit = 5;
$pageSize = 2;

// Read - fetches all messages eagerly and returns as a list
$messageList = $client->messages->read([], $limit);
foreach ($messageList as $msg) {
    print($msg->sid);
}

// Stream - returns an iterator of 'pageSize' messages at a time and lazily retrieves pages until 'limit' messages
$messageStream = $client->messages->stream([], $limit, $pageSize);
foreach ($messageStream as $msg) {
    print($msg->sid);
}

// Page - get the a single page by passing pageSize, pageToken and pageNumber
$messagePage = $client->messages->page([], $pageSize);
$nextPageData = $messagePage->nextPage();  // this will return data of next page
foreach ($messagePage as $msg) {
    print($msg->sid);
}

For more information about these methods, view the auto-generated library docs.

Use the read method

<?php
require_once '/path/to/vendor/autoload.php';

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

// Loop over the list of calls and print a property from each one
foreach ($client->calls->read() as $call) {
    print $call->direction;
}

Specify Region and/or Edge

To take advantage of Twilio's Global Infrastructure, specify the target Region and/or Edge for the client:

<?php
$sid = "ACXXXXXX";
$token = "YYYYYY";

$client = new Twilio\Rest\Client($sid, $token, null, 'au1');
$client->setEdge('sydney');

A Client constructor without these parameters will also look for TWILIO_REGION and TWILIO_EDGE variables inside the current environment.

This will result in the hostname transforming from api.twilio.com to api.sydney.au1.twilio.com.

Enable Debug Logging

There are two ways to enable debug logging in the default HTTP client. You can create an environment variable called TWILIO_LOG_LEVEL and set it to debug or you can set the log level to debug:

$sid = "ACXXXXXX";
$token = "YYYYYY";

$client = new Twilio\Rest\Client($sid, $token);
$client->setLogLevel('debug');

Generate TwiML

To control phone calls, your application needs to output TwiML.

Use Twilio\TwiML\(Voice|Messaging|Fax)Response to easily chain said responses.

<?php
$response = new Twilio\TwiML\VoiceResponse();
$response->say('Hello');
$response->play('https://api.twilio.com/cowbell.mp3', ['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>

Handle exceptions

When something goes wrong during client initialization, in an API request, or when creating TwiML, twilio-php will throw an appropriate exception. You should handle these exceptions to keep your application running and avoid unnecessary crashes.

The Twilio client

For example, it is possible to get an authentication exception when initiating your client, perhaps with the wrong credentials. This can be handled like so:

<?php
require_once('/path/to/twilio-php/Services/Twilio.php');

use Twilio\Exceptions\ConfigurationException;
use Twilio\Rest\Client;

$sid = "ACXXXXXX";
$token = "YYYYYY";

// Attempt to create a new Client, but your credentials may contain a typo
try {
    $client = new Twilio\Rest\Client($sid, $token);
} catch (ConfigurationException $e) {
    // You can `catch` the exception, and perform any recovery method of your choice
    print $e . getCode();
}

$call = $client->account->calls
    ->get("CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

print $call->to;

CurlClient

When initializing the curl client, you will see an EnvironmentException if curl is not installed on your system.

<?php
require_once('/path/to/twilio-php/Services/Twilio.php');

use Twilio\Exceptions\TwilioException;
use Twilio\Http\CurlClient;

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

try {
    $client = new CurlClient();

    $client->options(
        'GET',
        'http://api.twilio.com',
        array(),
        array(),
        array(),
        $sid,
        $token
    );
} catch (EnvironmentException $e) {
    print $e . getCode();
}

print $call->to;

TwilioException

TwilioException can be used to handle API errors, as shown below. This is the most common exception type that you will most likely use.

<?php
require_once('/path/to/twilio-php/Services/Twilio.php');

use Twilio\Exceptions\TwilioException;

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

try {
    $call = $client->account->calls
        ->get("CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
} catch (TwilioException $e) {
    print $e->getCode();
}

print $call->to;

TwimlException

When building TwiML with twilio-php, if the result does not conform to what the API expects, you will see a TwimlException which you then need to handle like so:

<?php
require_once './vendor/autoload.php';
use Twilio\Twiml;

try {
    $response = new Twiml();
    $dial = $response->dial();
    $dial->conference('Room 1234');
    print $response;
} catch (TwimlException $e) {
    print $e->getCode();
}

Debug API requests

To assist with debugging, the library allows you to access the underlying request and response objects. This capability is built into the default Curl client that ships with the library.

For example, you can retrieve the status code of the last response like so:

<?php
$sid = "ACXXXXXX";
$token = "YYYYYY";

$client = new Twilio\Rest\Client($sid, $token);
$message = $client->messages->create(
    '+15558675309',
    [
        'from' => '+15017250604',
        'body' => "Hey Jenny! Good luck on the bar exam!"
    ]
);

// Print the message's SID
print $message->sid;

// Print details about the last request
print $client->lastRequest->method;
print $client->lastRequest->url;
print $client->lastRequest->auth;
print $client->lastRequest->params;
print $client->lastRequest->headers;
print $client->lastRequest->data;

// Print details about the last response
print $client->lastResponse->statusCode;
print $client->lastResponse->body;

Use a custom HTTP Client

To use a custom HTTP client with this helper library, please see the advanced example of how to do so.

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 check the Twilio Support Help Center first, and file a support ticket if you don't find an answer to your question.

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

alexcchan avatar alexpayment avatar carlosdp avatar caseysoftware avatar childish-sambino avatar cjcodes avatar claudiachua avatar codejudas avatar dougblack avatar erickskrauch avatar eshanholtz avatar gipetto avatar ihumanable avatar ilanbiala avatar jennifermah avatar jingming avatar jmctwilio avatar jwitz10 avatar kevinburke avatar kyleconroy avatar luciferous avatar rvanlaak avatar shwetha-manvinkurke avatar sjlangley avatar skimbrel avatar thinkingserious avatar tiwarishubham635 avatar twilio-ci avatar twilio-dx avatar wanjunsli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

twilio-php's Issues

Simple class names conflict with namespace in applications

I've been integrating this library into a larger project (Cerb5), and it works well. The only problem I've been having is that the simple class names like Response, Redirect, and Verb can conflict with other class definitions from other project libraries. These classes should have the same prefix style used by TwilioException and TwilioClient.

I understand the desire to have a simple API where you can simply invoke new Say(), but in a larger project there are so many classes in the global namespace that there's nothing to group Say and Verb together with the rest of twilio-php. In PHP 5.3+ this could use the new namespaces functionality, but with PHP <= 5.2 it would be easy enough to just use class name prefixes.

Additionally it might be worth a refactor to get rid of all the extra classes and simply make them methods. ->Say() lends itself better to introspection than new Say() does.

If I find some time, or start to use the TwiML API in addition to the REST one, I'll give it a go. :)

if_machine documentation problem

The official documentation on readthedocs.com says to include an array with a parameter labeled "if_machine" which is inaccurate. The only way I got this to work was by including "IfMachine" => "Continue" - same goes for status_callback

the getPage() interface is clunky

problems: the third parameter is usually the most important, you expect a Page to be an array of resources, but instead it's an object, and the array is buried as a parameter on that page object.

twilio-php needs to handle unexpected responses from Twilio

We saw a few occurrences of this exception in our error logs this morning, coming from Services_Twilio:

(DomainException) Unexpected content type: text/html

There wasn't a lot of information about it, but I assume this was some sort of transient internal error at Twilio being exposed to API clients. It went away on its own by noon (PDT) today.

But if this is a possible outcome of an API call, the API client needs to handle it gracefully.

At least we're still using version 3.2.2 of the library; I see that the newest version would not even notice the lack of a valid JSON response, pass HTML to json_decode, and trigger strange errors in the caller by trying to access properties on false.

I would suggest putting the content type check back in, and to help me not panic in the future, have the exception also indicate the HTTP status so I can see if there's just some transient problem.

Cannot find Services_Twilio_RestException

Getting this message when posting and producing an error.

Fatal error: Uncaught exception 'Services_Twilio_RestException' with message 'The requested resource was not found' in [MY PATH]\Services\Twilio.php:149

No exception info available when using junk number

When using the PHP helper lib and making a call (.json) using a bogus number, I'm expecting to get back a Services_Twilio_Rest_Call Object with "Exception" qualities: status, message, code, etc. However, I get nothing back. Am I doing this wrong?

try { 
// Initiate a new outbound call 
$call = $this->client->account->calls->create( 
$this->from_phone, 
$this->to_phone, // Something bogus like 23424 
$this->callback_url, 
$params 
); 
return $call; 
} catch (Services_Twilio_RestException $e) { 
// Error stuff 
}

Pear install Fails

The instructions in the README say to do this:

pear channel-discover twilio.github.com/pear
pear install twilio/Services_Twilio

But when I run the first command i get this output

pear channel-discover twilio.github.com/pear
Discovering channel twilio.github.com/pear over http:// failed with message: channel-add: Cannot open   "http://twilio.github.com/pear/channel.xml" (could not open /var/tmp/channel.xml for writing)
Trying to discover channel twilio.github.com/pear over https:// instead
Discovery of channel "twilio.github.com/pear" failed (channel-add: Cannot open "https://twilio.github.com/pear/channel.xml" (Connection to `twilio.github.com:443' failed: Connection refused))

Validate AccountSid and Auth Token when passed into client

Perform basic regex checking of the account sid and auth token when they are passed in (eg should be 32 digit hex number), to help people debug the "401 Authenticate" error message. Should only issue a warning, for forward compatibility if Twilio decides to change those values later.

fetch more then 30 phone numbers from twilio

Hi,
I want to fetch more then 30 phone numbers from twilio server.
At a one time it gives only 30 phone numbers and when i search again for next 30 numbers then it repeats the same 30 numbers which i have seen in my previous search.

Error Running Twilio

I'm getting this error when trying to run twilio. I installed it using pear.
Fatal error: Class 'TinyHttpException' not found in C:\PHP5\PEAR\Services\Twilio\TinyHttp.php on line 89

passing boolean values to twiml creates 1|0 attribtue values

Noticed that the Twiml class doesn't allow you to use actual boolean values when passing in options.

This doesn't work:

$response->record(
    array(
        'action' => "handle_recording.php",
        'maxLength' => '60',
        'transcribe' => true
    )
);

instead of using true, it has to be a string. So at line 86 of Twiml.php I added the following to fix it:

if(is_bool($value))
     $value = ($value === true ? 'true' : 'false');

Fatal error: Cannot redeclare services_twilio_autoload()

I consistently get this error on my local machine (OSX running MAMP with PHP 5.3.6) but do not have this problem on a different server running PHP 5.3.3. When I switch my local machine to use PHP 5.2.17 the issue also goes away. I suspect the issue isn't the PHP version, but rather something in the server configuration. However, the reported error message does not give me enough information to debug the problem. The fatal error in question is:

Fatal error: Cannot redeclare services_twilio_autoload() in /local/path/to/twilio.php on line 3

Line 3 is the first place Services_Twilio_autoload is defined, so I cannot figure out why it might be trying to redeclare itself.

Freezes on Iteration

Hello,

I am having the problem that it seems to freeze when I am iterating through the participants in a conference. I can get the conference itself, but as soon as I put the participants property in a foreach loop, it freezes.
Is there any idea why this might be happening?

I'm using the latest release of twilio-php on PHP 5.3.9.

Here's a code sample.

$conferences = $client->account->conferences->getIterator(
0, 50, array('FriendlyName' => 'Holding', 'Status' => 'in-progress'));

foreach ($conferences as $i => $conference)
{
foreach ($conference->participants as $participant)
{
// Even this is enough to freeze it.
}
}

Application class missing

I was able to run this:

sudo pear channel-discover twilio.github.com/pear
sudo pear install twilio/Services_Twilio

but then when I run this simple script:

$client = new Services_Twilio($AccountSid, $AuthToken);

and i get these errors:

PHP Warning: include(/usr/share/pear/Services/Twilio/Rest/Applications.php): failed to open stream: No such file or directory in /usr/share/pear/Services/Twilio.php on line 9

Warning: include(/usr/share/pear/Services/Twilio/Rest/Applications.php): failed to open stream: No such file or directory in /usr/share/pear/Services/Twilio.php on line 9
PHP Warning: include(): Failed opening '/usr/share/pear/Services/Twilio/Rest/Applications.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /usr/share/pear/Services/Twilio.php on line 9

Warning: include(): Failed opening '/usr/share/pear/Services/Twilio/Rest/Applications.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /usr/share/pear/Services/Twilio.php on line 9
PHP Fatal error: Class 'Services_Twilio_Rest_Applications' not found in /usr/share/pear/Services/Twilio/Resource.php on line 67

Fatal error: Class 'Services_Twilio_Rest_Applications' not found in /usr/share/pear/Services/Twilio/Resource.php on line 67

shawn parker reports issue

ERROR - 2011-11-02 18:29:36 --> Severity: Notice --> Undefined property: stdClass::$available_phone_numbers /home/content/84/7048584/html/vbx1.1/OpenVBX/libraries/Services/Twilio/ListResource.php 111
ERROR - 2011-11-02 18:29:36 --> Severity: Warning --> array_map() [function.array-map]: Argument #2 should be an array /home/content/84/7048584/html/vbx1.1/OpenVBX/libraries/Services/Twilio/ListResource.php 112

Seems like there should be some variable availability checking done before performing that operation.

error in example_utils.php

if($_SERVER['HTTPS'])
    $http = "http://";
else
    $http = "https://";

should be

if($_SERVER['HTTPS'])
    $http = "https://";
else
    $http = "http://";

-FT

$message object should print useful data

It's difficult to debug a created SMS message to figure out what should be there. echo $message prints an empty string, and echo print_r($message, true) returns a large mess including the http object.

Also consider adding toString methods for $call, etc.

Apache with SSL causes Seg Fault

I'm running into an issue where enabling SSL on Apache2, causes a PHP Seg Fault every time the Twilio library initiates a call/sms. Any ideas as to where I should start poking around in the code?

SSL Error

Fatal error: Uncaught exception 'Services_Twilio_TinyHttpException' with message 'SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed' in [MY PATH]\Services\Twilio\TinyHttp.php:89

Fatal error when updating a phone number

We are having an issue where the library seems to be doubling the ".json" string in $this->uri.

Reproduce code

define('TWILIO_ACCOUNT_SID', '');
define('TWILIO_AUTH_TOKEN', '');
define('PURCHASED_NUMBER_SID', '');

$client = new Services_Twilio(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN);

// get a number from your account
$purchasedNumber = $client->account->incoming_phone_numbers->get(PURCHASED_NUMBER_SID);

// update the number
$purchasedNumber->update(array(
  'VoiceMethod' => 'POST',
  'VoiceUrl'    => 'http://twimlets.com/forward?PhoneNumber=thisisatest'
));

Result

PHP Fatal error:  Uncaught exception 'Services_Twilio_RestException' with message 'The requested resource /2010-04-01/Accounts/XXXXXXXXXXXX/IncomingPhoneNumbers/XXXXXXXXXXXXXXXXX.json.json was not found' in /home/dbowen/scratch/lib/Services/Twilio.php:213
Stack trace:
#0 /home/dbowen/scratch/lib/Services/Twilio.php(185): Services_Twilio->_processResponse(Array)
#1 /home/dbowen/scratch/lib/Services/Twilio/InstanceResource.php(26): Services_Twilio->createData('/2010-04-01/Acc...', Array)
#2 /home/dbowen/scratch/twilio_test/test.php(29): Services_Twilio_InstanceResource->update(Array)
#3 {main}
  thrown in /home/dbowen/scratch/lib/Services/Twilio.php on line 213

Note the ".json.json" string in the resource URI within the exception message.

Patch

at the top of Services_Twilio::createData()

replace:

$path = "$path.json";

with:

if (substr($path, -5) != '.json')
{
  $path = "$path.json";
}

DomainException Issue

Uncaught exception 'DomainException' with message 'Response was neither JSON nor XML'

require_once('../twilio-php/Services/Twilio.php');                                                                                                                                 
$twilio = new Services_Twilio($api,$key);                                                                                                                                          
$to = $_POST['To'];                                                                                                                                                                
$message = 'I have recieve the command and executed it';                                                                                                                           
$sms = $twilio->account->sms->create($to,$from,$message);     

also 
$sms = $twilio->account->sms_messages do the same->create($to,$from,$message);     


PHP Fatal error:  Uncaught exception 'DomainException' with message 'Response was neither JSON nor XML' in /api/twilio-php/Services/Twilio.php:133

getIterator does not show total

Based on the documentation it previously allowed ->total, but now only getPage() does.

http://www.twilio.com/docs/howto/twilio-client-browser-conference-call-monitor

Also the documentation is showing incorrectly to use total in array format instead of object format.

It should read like this

$conferences = $client->account->conferences->getPage(0, 50, array('Status' => 'in-progress'));
echo '<p>Found '.$conferences->total.' conference(s)</p>';

http://forum.twilio.com/twilio/topics/cannot_use_object_of_type_services_twilio_autopagingiterator_as_array

Unable to get call duration

I was unable to get call duration in specific call sid.

require realpath($_SERVER['DOCUMENT_ROOT']).'/Services/Twilio.php';

$client   = new Services_Twilio(AccountSid,AuthToken);
$duration = $client->account->calls->get(@$_REQUEST['CallSid'])->duration;
echo $duration;

Is there a way I can easily get the call duration in specific call sid?

Cannot release numbers

This PHP can provision numbers, but I don't see any way to release numbers with it, even though the ability to release numbers is supported by Twilio's REST API (http://www.twilio.com/docs/api/rest/incoming-phone-numbers#instance-delete) -- There's no mention of how to release numbers in the docs... and when digging into the code, it doesn't seem possible.

This doesn't work:

$number = $this->twilio->account->incoming_phone_numbers->get(PN...);
$number->delete();

How to get a phone number in account by phone number string

How to get a phone number in account by specifying it by a phone number string?
How can I do this without iterating through all the phone numbers?

Iterating through all numbers:
$client = new Services_Twilio($account_sid, $auth_token);
$numbers = $client->account->incoming_phone_numbers;
foreach($numbers as $number) { ... }

I want to get an incoming_phone_number by specifying the number ex. "441234567"?
I don't have the SID.

The example in README

The TwiML example doesn't seem correct

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

Note on what is being called and the resulting TwiML

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.