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 bulk SMS to a list of contacts


When you have a big product launch and you want to notify your users or send out a promotion, this is the script you would use.

Getting ready

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

How to do it...

We're going to build an app in this section that will let us send a message to a list of contacts. This is handy for advertising new promotions with your business.

  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 bulk.php to your server and add the following code to it:

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