Book Image

Twilio Best Practices

Book Image

Twilio Best Practices

Overview of this book

Table of Contents (15 chapters)
Twilio Best Practices
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

How does Twilio Client work?


There are four steps to follow when working with Twilio Client:

  1. Setting it up with your credentials

  2. Placing outgoing calls

  3. Dealing with incoming calls

  4. Interacting with calls currently in progress

Setting up the client

To get started, you'll use your language's Twilio API library to generate a Capability Token. This gives the client the right to make and/or receive calls using your account.

The following are embedded in this token:

  • Your account credentials, ensuring that only you can give clients the right to make and receive calls using your Twilio credit

  • The identifier that will be used to receive calls (if the client is allowed to receive calls)

  • The Twilio application SID that will be used to place outgoing calls (if the client is allowed to place outgoing calls)

As an example, using the PHP library, we'll generate a Client token like this:

$accountSid = '<your account SID>';
$authToken  = '<your auth token>';
$capability = new Services_Twilio_Capability($accountSid...