Skip to content

Instantly share code, notes, and snippets.

@jmadden
Last active April 6, 2022 03:02
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmadden/562d50eb0c9a427ac141f9e8da6e57b5 to your computer and use it in GitHub Desktop.
Save jmadden/562d50eb0c9a427ac141f9e8da6e57b5 to your computer and use it in GitHub Desktop.
Sequentially dial phone numbers using Twilio and Twilio's PHP helper library
<?php
// Require the bundled autoload file - the path may need to change
// based on where you downloaded and unzipped the SDK
require __DIR__ . '/twilio-php-master/Twilio/autoload.php';
// Use Twilio\TwiML to build TwiML instructions through PHP
use Twilio\Twiml;
// Instantiate a TwiML object.
$response = new Twiml();
// Fill this array with phone numbers to be called. List them in order of importance.
// The included phone numbers are fake example numbers so be sure to change them.
$callToArr = (1 => '+15554441212', 2 => '+16667778989');
if (isset($_REQUEST['index'])) {
$index = $_REQUEST['index'];
} else {
$index = 1;
}
if ($index <= count($callToArr)){
$next = $index + 1;
$dial = $response->dial(['timeout' => 15,'action' => '/sequential_dialing.php?index='.$next], );
$dial->number($callToArr[$index]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment