[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 =========================== 2 Generate Capability Tokens 3 =========================== 4 5 `Twilio Client <http://www.twilio.com/api/client>`_ allows you to make and recieve connections in the browser. You can place a call to a phone on the PSTN network, all without leaving your browser. See the `Twilio Client Quickstart <http:/www.twilio.com/docs/quickstart/client>`_ to get up and running with Twilio Client. 6 7 Capability tokens are used by `Twilio Client <http://www.twilio.com/api/client>`_ to provide connection security and authorization. The `Capability Token documentation <http://www.twilio.con/docs/tokens>`_ explains indepth the purpose and features of these tokens. 8 9 :php:class:`Services_Twilio_Capability` is responsible for the creation of these capability tokens. You'll need your Twilio AccountSid and AuthToken. 10 11 .. code-block:: php 12 13 require('/path/to/twilio-php/Services/Twilio/Capability.php'); 14 15 $accountSid = "AC123123"; 16 $authToken = "secret"; 17 18 $capability = new Services_Twilio_Capability($accountSid, $authToken); 19 20 21 Allow Incoming Connections 22 ============================== 23 24 Before a device running `Twilio Client <http://www.twilio.com/api/client>`_ can recieve incoming connections, the instance must first register a name (such as "Alice" or "Bob"). The :php:meth:`allowCclientIncoming` method adds the client name to the capability token. 25 26 .. code-block:: php 27 28 $capability->allowClientIncoming("Alice"); 29 30 31 Allow Outgoing Connections 32 ============================== 33 34 To make an outgoing connection from a `Twilio Client <http://www.twilio.com/api/client>`_ device, you'll need to choose a `Twilio Application <http://www.twilio.com/docs/api/rest/applications>`_ to handle TwiML URLs. A Twilio Application is a collection of URLs responsible for outputing valid TwiML to control phone calls and SMS. 35 36 .. code-block:: php 37 38 $applicationSid = "AP123123"; // Twilio Application Sid 39 $capability->allowClientOutgoing($applicationSid); 40 41 :php:meth:`allowClientOutgoing` accepts an optional array of parameters. These parameters will be passed along when Twilio requests TwiML from the application. 42 43 .. code-block:: php 44 45 $applicationSid = "AP123123"; // Twilio Application Sid 46 $params = array("Foo" => "Bar"); // Parameters to be passed 47 $capability->allowClientOutgoing($applicationSid, $params); 48 49 50 Generate a Token 51 ================== 52 53 .. code-block:: php 54 55 $token = $capability->generateToken(); 56 57 By default, this token will expire in one hour. If you'd like to change the token expiration time, :php:meth:`generateToken` takes an optional argument which specifies `time to live` in seconds. 58 59 .. code-block:: php 60 61 $token = $capability->generateToken(600); 62 63 This token will now expire in 10 minutes. 64
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |