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

Building a survey tree


The survey builder performs three functions: it shows you the stats on sent surveys, lets you send unsent surveys, and lets you build your new surveys.

Surveys in this system are simple: one question and six possible answers.

Each answer will be assigned a number of 1 to 6.

Getting ready

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

How to do it...

We've got subscribers but we need to send them what they've subscribed to. This recipe will set up our survey builder. We'll also build a home page as part of our builder, where we can choose to send surveys or view results.

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

  2. Upload the Services/ folder to your website.

  3. Create a file on your website and name it survey-builder.php. The file will have the following content:

    <?php
    include("config.php");
    include("pdo.class.php");
    include 'Services/Twilio.php';
    switch($_GET['action'] ){
      case...