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

Receiving incoming calls in the browser


We've now made an outgoing phone call from within the browser, but we're yet to see how receiving a call works.

To demonstrate this, let's build a page where our imaginary technical support team can take calls from customers in their browsers.

In the same directory as before, create a PHP file called tech.php that should contain the following:

<?php
// To start, you'll need to include the Twilio PHP library, and particularly
// the Capability functionality. Replace this with the path to where you have
// the library installed, or the autoload file if you're using Composer.
require 'Services/Twilio/Capability.php';
// Add your own API credentials here - we'll need these to generate a token
$accountSid = '<your account SID>';
$authToken  = '<your auth token>';
$capability = new Services_Twilio_Capability($accountSid, $authToken);
$capability->allowClientIncoming("techsupport");
$token = $capability->generateToken();
?>
<!DOCTYPE...