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

Sending a message from a website


Sending messages from a website has many uses; sending notifications to users is one good example. In this example, we're going to present you with a form where you can enter a phone number and message and send it to your user. This can be quickly adapted for other uses.

Getting ready

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

How to do it...

Ok, let's learn how to send an SMS message from a website. The user will be prompted to fill out a form that will send the SMS message to the phone number entered in the form.

  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
    ?>
  4. Upload a file called...