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

Letting a user purchase a custom phone number


Ok, once a user has signed up, he/she is going to need a phone number that he/she can call his/her own.

On signup, we forward the user to the /phone-number object, which is what we'll build in this recipe.

Getting ready

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

How to do it...

Our app will walk users through the process of searching for and purchasing a phone number using the following steps:

  1. Update the following index.php file:

    <?php
    include 'Services/Twilio.php';
    require("config.php");
    require("system/jolt.php");
    require("system/pdo.class.php");
    require("system/functions.php");
    
    $_GET['route'] = isset($_GET['route']) ? '/'.$_GET['route'] : '/';
    $app = new Jolt('site',false);
    $app->option('source', 'config.ini');
    #$pdo = Db::singleton();
    $mysiteURL = $app->option('site.url');
    
    $app->condition('signed_in', function () use ($app) {
            $app->redirect( $app...