Book Image

Twilio Cookbook: Second Edition

By : Roger Stringer
Book Image

Twilio Cookbook: Second Edition

By: Roger Stringer

Overview of this book

Table of Contents (20 chapters)
Twilio Cookbook Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Forwarding SMS messages to another phone number


This recipe can be handy when you want to forward SMS messages you received from one phone number on your cell phone.

Getting ready

The complete source code for this recipe can be found in the Chapter6/Recipe3/ folder.

How to do it...

We're about to build a web app that will listen to incoming SMS messages and forward them to another phone number.

  1. Download the Twilio Helper Library from https://github.com/twilio/twilio-php/zipball/master and unzip it.

  2. Upload the Services/ folder to your website.

  3. Upload config.php to your website and make sure the following variables are set:

    <?php
    $accountsid = '';  //  YOUR TWILIO ACCOUNT SID
    $authtoken = '';   //  YOUR TWILIO AUTH TOKEN
    $fromNumber = '';  //  PHONE NUMBER CALLS WILL COME FROM
    $toNumber = '';    // YOUR PHONE NUMBER TO FORWARD SMS TO
    ?>
  4. Upload forward.php to your server and add the following code to it:

    <?php
      include 'Services/Twilio.php';
    
      include("config.php");
      include("functions.php...