MAJOR version bumps will have upgrade notes posted here.
Twilio Php Helper Library’s major version 7.0.1 is now available. We ensured that you can upgrade to Php helper Library 7.0.1 version without any breaking changes. Behind the scenes Php Helper is now auto-generated via OpenAPI with this release. This enables us to rapidly add new features and enhance consistency across versions and languages.
To learn more about the Php Helper Library, check out our docs.
Custom headers are now supported in twilio-php
. The addition of these optional parameters have caused a breaking change to the read
, page
, and stream
functions for Entity
, Service
, and Factor
resources. These functions now expect an array of optional parameters as the first argument.
<?
use Twilio\Rest\Client;
$twilio = new Client();
$entities = $twilio->authy->v1->services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
->entities
->read(20);
<?
use Twilio\Rest\Client;
$twilio = new Client();
$entities = $twilio->authy->v1->services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
->entities
->read([], 20);
Version 6.x.x
is the first version that officially drops support for Php versions 5.5, 5.6, 7.0, and 7.1.
- Drop 'array()' syntax and add return types
- Drop 'array()' syntax and add return types in generated code
- Add scalar param type declarations
- Add scalar param type declarations to generated code
- Drop support for end of life Php versions
A TypeError may now be thrown if you pass an incompatible type into a php helper library function or if you depend on an incompatible return type from a Php helper library function.
This was changed to add support for sending media in Chat messages, users can now either provide a body
or a media_sid
.
<?php
use Twilio\Rest\Client;
$client = new Client();
$client->chat->v2->service('IS123')->channel('CH123')->message->create("this is the body");
<?php
use Twilio\Rest\Client;
$client = new Client();
$client->chat->v2->service('IS123')->channel('CH123')->message->create(array("body"=>"this is the body"));
CHANGED - Rename room Recordings
resource to RoomRecordings
to avoid class name conflict (backwards incompatible).
<?php
use Twilio\Rest\Client;
$client = new Client();
$client->api->v2010->sandbox->read();
Not Supported.
The Sandbox resource has been removed from the API and is no longer supported.
<?php
use Twilio\Rest\Client;
$client = new Client();
// Access api.twilio.com/2010-04-01/Accounts
$client->accounts->read();
<?php
use Twilio\Rest\Client;
$client = new Client();
// Access accounts.twilio.com/v1
$client->accounts;
// Access new PublicKeys resource
$client->accounts->credentials->publicKey->read();
// Access api.twilio.com/2010-04-01/Accounts
$client->api->v2010->accounts->read();
accounts.twilio.com
is now publicly available, following our convention of
accessing subdomains of twilio via client->{subdomain}
we replaced the shortcut
to 2010 Accounts with a reference to the new Accounts subdomain. 2010 Accounts
are still accessible the long way client->api->v2010->accounts
or client->api->accounts
.
<?php
use Twilio\Rest\Client;
$client = new Client();
$client->chat->messages->read(10); // limit to 10 messages
<?php
use Twilio\Rest\Client;
$client = new Client();
$client->chat->messages->read(array(), 10); // limit to 10 messages
$client->chat->messages->read(array(
"order" => "asc"
), 10); // limit to 10 messages and filter by order
Options arrays are placed at the beginning of the function signature if the resource accepts optional params and is ommited if the resource does not accept any. Chat messages previously did not accept any optional params and now do.
- the
uri
property on this object has been removed and is no longer returned by the api. - the
url
property is still present and unchanged and should be used instead of theuri
property.
This corrects a oversight in our code generation, new style resources such as this use url
and links
properties
while legacy resources use uri
and subresource_uris
. Previously we were incorrectly returning both uri
and url
.
- Listing some resources and filtering by
StartDate<
,StartDate>
,EndDate<
, andEndDate>
will no longer work. - Filtering by
StartDate
andEndDate
will continue to work, these dates are inclusive. StartDate
andEndDate
params are nowDateTime
objects rather thanstrings
. They will automcatically be converted to UTC timezone, the original DateTime object will not be modified.
- All Account Usage Record Resources (Last Month, This Month, Yesterday, All Time, Monthly, Yearly, Today, Daily).
- Monitor Alerts, Events.
- Taskrouter All Statistics endpoints (Workspace, TaskQueues, Workers...), Workspace Events.
- Call Feedback Summaries.
<?php
use Twilio\Rest\Client;
$client = new Client();
$client->usage->records->read(array(
"StartDate" => "1999-09-07",
"EndDate<" => "2000-01-01" // Allowed but would have had no effect.
));
<?php
use Twilio\Rest\Client;
$startDate = new DateTime("now", new DateTimeZone("America/Los_Angeles"));
$endDate = clone $startDate;
$endDate->add(new DateInterval("P2D")); // Add 2 days
$client = new Client();
$client->usage->records->read(array(
"StartDate" => $startDate,
"EndDate" => $endDate
));
// Passing strings will still work
$client->usage->records->read(array(
"StartDate" => "1999-09-07" // OK
));
Not serializing API Dates into DateTimes was an oversight initially, removing library support for date inequality filters (ie StartDate>
etc) brings the library into alignment with the API behavior. Only select resources on our 2010 API support date inequalities, date inequalities were included on unsupported resources mistakenly and that functionality would never have worked anyways.
- Reading members of channel and listing channels now takes an array of options as is its first argument.
- Affects the
read
,stream
, andpage
methods of MemberList.
<?php
use Twilio\Rest\Client;
$client = new Client();
$client->chat->v1->services('IS123')->channels('CH123')->members->read(10);
$client->chat->v1->services('IS123')->channels->read(10);
<?php
use Twilio\Rest\Client;
$client = new Client();
$client->chat->v1->services('IS123')->channels('CH123')->members->read(array(), 10);
$client->chat->v1->services('IS123')->channels->read(array(), 10);
$client->chat->v1->services('IS123')->channels('CH123')->members->read(array('type' => 'public'), 10);
<?php
use Twilio\Rest\Client;
$client = new Client();
$client->chat->v1->services('IS123')->channels('CH123')->update(array('type'=>'public'));
Not Supported
Make library consistent with public API, changing channel type was never supported and wouldnt have worked in previous versions anyways.
- Updating a message body no longer requires passing the body directly and is not required.
<?php
use Twilio\Rest\Client;
$client = new Client();
$client->chat->v1->services('IS123')->channels('CH123')->messages('IM123')->update('new body', array());
<?php
use Twilio\Rest\Client;
$client = new Client();
$client->chat->v1->services('IS123')->channels('CH123')->messages('IM123')->update(array('body' => 'new body'));
This is a correction for what the API actually expects.
- Updating a taskrouter activity now optionally takes a
friendlyName
parameter (was previously required). - Creating a taskrouter activity now optionally takes a
available
parameter (was previously required). - Creating a taskrouter task now optional takes
workflowSid
andattributes
(were both previously required).
<?php
use Twilio\Rest\Client;
$client = new Client();
$client->taskrouter->v1->workspaces('WS123')->activities('WA123')->update('new friendly name');
$client->taskrouter->v1->workspaces('WS123')->activities->create('new friendly name', true);
$client->taskrouter->v1->workspaces('WS123')->tasks->create('attributes', 'WW123', array('timeout' => 10));
<?php
use Twilio\Rest\Client;
$client = new Client();
$client->taskrouter->v1->workspaces('WS123')->activities('WA123')->update(array('friendlyName' => 'new friendly name'));
$client->taskrouter->v1->workspaces('WS123')->activities->create('new friendly name', array('available' => true));
$client->taskrouter->v1->workspaces('WS123')->tasks->create(array(
'attributes' => 'attributes',
'workflowSid' => 'WW123',
'timeout' => 10
));
This is a correction for what the API actually expects.
- Previous version incorrectly allowed setting a
taskChannel
on aTaskReadOptions
object, this is no longer supported.
This is a correction for what the API actually allows. Previous versions allowed this to be set but it would not have had any effect.
<?php
use Twilio\Rest\Client;
$client = new Client();
// Get statistics for a single task queue
$taskQueue = $client->taskrouter->v1->workspaces('WS123')->taskQueues('WQ123')->fetch();
$taskQueueStatistics = $taskQueue->getStatistics();
// Get statistics for all task queues
$client->taskrouter->v1->workspaces('WS123')->taskQueues->getStatistics();
<?php
use Twilio\Rest\Client;
$client = new Client();
// Get statistics for a single task queue
$taskQueue = $client->taskrouter->v1->workspaces('WS123')->taskQueues('WQ123')->fetch();
$taskQueueStatistics = $taskQueue->getTaskQueueStatistics();
// Get statistics for all task queues
$client->taskrouter->v1->workspaces('WS123')->taskQueues->getTaskQueuesStatistics();
There was a naming conflict between TaskQueueStatistics and TaskQueuesStatistics. Both were trying to generate
methods named getStatistics
.
- Updating a message body now requires passing the body directly and is required.
<?php
use Twilio\Rest\Client;
$client = new Client();
$client->api->v2010->accounts('AC123')->messages('MM123')->update(array('body' => ''));
<?php
use Twilio\Rest\Client;
$client = new Client();
$client->api->v2010->accounts('AC123')->messages('MM123')->update('');
This is used to redact a message body and the api expects the body parameter to be present, allowing this to be an optional parameter was an oversight.
- Updating a message body now requires passing the body directly and is required.
<?php
use Twilio\Rest\Client;
$client = new Client();
$client->api->v2010->accounts('AC123')->queues('QU123')->create(array('friendlyName' => 'Test'));
<?php
use Twilio\Rest\Client;
$client = new Client();
$client->api->v2010->accounts('AC123')->queues('QU123')->create('Test', array());
This was made to enforce consistency with the API, the API will return a 400 if a friendlyName is not provided.
RoleInstance::update(string $friendlyName, string[] $permission)
toRoleInstance::update(string[] $permission)
RoleContext::update(string $friendlyName, string[] $permission)
toRoleContext::update(string[] $permission)
<?php
use Twilio\Rest\Client;
$client = new Client();
$client->chat->services('IS123')->roles('RL123')->update('Example Role', array('permission'));
<?php
use Twilio\Rest\Client;
$client = new Client();
$client->chat->services('IS123')->roles('RL123')->update(array('permission'));
Role Updates do not support updating the friendlyName.
Page::processResponse(Response $response) throws DeserializeException
toPage::processResponse(Response $response) throws RestException
<?php
use Twilio\Rest\Client;
use Twilio\Exceptions\DeserializeException;
$client = new Client();
try {
$calls = $client->calls->read();
} catch (DeserializeException $e) {
echo("Error reading: {$e->getMessage()}");
}
<?php
use Twilio\Rest\Client;
use Twilio\Exceptions\RestException;
$client = new Client();
try {
$calls = $client->calls->read();
} catch (RestException $e) {
echo("Error reading: {$e->getMessage()}");
}
Alternatively
<?php
use Twilio\Rest\Client;
use Twilio\Exceptions\TwilioException;
$client = new Client();
try {
$calls = $client->calls->read();
} catch (TwilioException $e) {
echo("Error reading: {$e->getMessage()}");
}
Exceptions were improved to include more information about what went wrong. The
Page
class that is used by read
and stream
was missed, this bring Page
up to parity with other exceptions.
The Exception class was changed to reflect that the failure is not in processing the response (Deserialization) but that the response is invalid (Rest).
CredentialInstance::update(string $username, string $password)
toCredentialInstance::update(array|CredentialOptions $options)
CredentialContext::update(string $username, string $password)
toCredentialContext::update(array|CredentialOptions $options)
<?php
use Twilio\Rest\Client;
$client = new Client();
$client->sip->credentialLists('CL123')->credentials('CA123')->update('username', 'password');
<?php
use Twilio\Rest\Client;
$client = new Client();
$client->sip->credentialLists('CL123')->credentials('CA123')->update(array(
'password' => 'password'
));
Credential Updates only supported Updating the password and it is an optional parameter.
<?php
use Twilio\Rest\Client;
$client = new Client();
$client->chat->v1->services('IS123')->users->create('identity', 'RL123');
<?php
use Twilio\Rest\Client;
$client = new Client();
$client->chat->v1->services('IS123')->users->create('identity', array(
'roleSid' => 'RL123'
));
As the Chat product has evolved, we have added a default Role sid to User creation making the parameter optional.
ParticipantInstance::update(boolean $muted)
toParticipantInstance::update(array|ParticipantOptions $options)
ParticipantContext::update(boolean $muted)
toParticipantContext::update(array|ParticipantOptions $options)
<?php
use Twilio\Rest\Client;
$client = new Client();
$client->conferences('CF123')->participants('CA123')->update(true);
<?php
use Twilio\Rest\Client;
$client = new Client();
$client->conferences('CF123')->participants('CA123')->update(array(
'muted' => true,
));
Conference Participants actually support a wider range of mutations than the
5.1.x
library supported. Mute was incorrectly marked as a required
property
when it is actually optional
. This change allows the library to provide
support for the full range of mutation options.
Option | Definition |
---|---|
hold | Specifying true will hold the participant, while false will un-hold. |
holdUrl | The 'HoldUrl' attribute lets you specify a URL for music that plays when a participant is held. The URL may be an MP3, a WAV or a TwiML document that uses or . |
holdMethod | Specify GET or POST, defaults to POST |
muted | Specifying true will mute the participant, while false will un-mute. Anything other than true or false is interpreted as false. |
WorkflowList::create(string $friendlyName, string $configuration, string $assignmentCallbackUrl, array|WorkflowOptions $options)
toWorkflowList::create(string $friendlyName, string $configuration, array|WorkflowOptions $options)
<?php
use Twilio\Rest\Client;
$client = new Client();
$client->taskrouter->workspaces('WS123')->workflows->create(
'My New Workflow',
'{...}',
'http://assignment-callback-url.com'
);
<?php
use Twilio\Rest\Client;
$client = new Client();
$client->taskrouter->workspaces('WS123')->workflows->create(
'My New Workflow',
'{...}',
array(
'assignmentCallbackUrl' => 'http://assignment-callback-url.com',
)
);
When Taskrouter was first released all workflows had to communicate reservations
back to a server for handling. As the product has matured a capable JavaScript
SDK has been released that can handle reservations. This change allows one to
use Taskrouter without an assignmentCallbackUrl
instead using the client
events to handle reservations.