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

Replying to a message from the phone


When a user replies to a message from his/her phone, we want to store it in the database so that we can review the messages later.

Getting ready

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

How to do it...

We're going to build a simple app that will receive SMS messages and store them in a database. When we receive SMS messages, we will store them inside the database along with the phone number the message came from and the unique SID.

  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. Create a MySQL database and load the contents of sql.sql into the database.

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

    <?php
    $accountsid = '';  //  YOUR TWILIO ACCOUNT SID
    $authtoken = '';   //  YOUR TWILIO AUTH TOKEN
    $fromNumber = '';  //  PHONE NUMBER CALLS WILL COME FROM
    $dbhost = '';...