Practical] Summary of how to make a call from your browser to your cell phone using Twilio.

Medium 7865430650

photo credit: CalEvans via photopin cc

Good evening, this is Bono.

This year, we have used Twilio several times for hackathons.

Twilio is still in its infancy, but we believe that it is one of the services that will be transformed in the near future.

Developer interest is also quite high, and there are always teams using this service when they participate in hackathons.

In this issue, we leave as a reminder how to make a phone call from a browser.

What is Twilio?

IP phone calls are easy to make!

NewImage

Twilio for KDDI Web Communications

Twilio is a service that makes IP telephony easy to use.

In Japan, KDDI provides this service. The core part of actually "making a call" is provided by the API, and developers can focus only on "how to use" it.

Extensive documentation available.

The service is well documented, and it is a good idea to look for the parts you don't understand there.

Again, the following pages basically follow the contents of the following pages.

Twilio Docs - HowTo Twilio Client Click To Call

First, preparation

Register your phone number

First, register your phone number according to the following site.

A Touch with Twilio | Casley Consulting Technology Blog

Upon registration, you will receive an ACCOUNT SID and AUTH TOKEN as follows

Skitch

Library Installation

You cannot make a call without a library.

It is a little confusing, but the library is uploaded on GitHub, so download it.

https://github.com/twilio/twilio-php/tree/master/Services

Perform initial setup to use the application

Create a file named browsephone.php and enter the following

[crayon] php
include 'Services/Twilio/Capability.php';.

$accountSid = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$authToken = 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY';

$capability = new Services_Twilio_Capability($accountSid, $authToken);
$capability->allowClientOutgoing('APZZZZZZZZZZZZZZZZZZZZZZZZ');
? >
[/crayon]

Note that for X and Y, click on the dashboard and enter the number in "ACCOUNT SID" and the number in "AUTH TOKEN".

twilio

Enter the id assigned to each application in Z.

Select the application from "Tools" > "TWIML APPS" and enter the value in the "Sid" field beyond it.

twilio

Create dial section

Add the following to browsephone.php

Create a dialing section for making phone calls.

Note that this is just a copy and paste of the sample code.

[crayon]


[/crayon]

Create View

Add the following to browsephone.php

Place buttons, etc. for dialing.

Here, N enters the phone number you want to call.

Note that this is the same number as an international call.

[crayon]

Offline
[/crayon]

Finally, check from the browser

Now all you have to do is open your browser and press the "Start Call" button to make a call to the phone listed above.

Easy!

twilio