Skip to content

Instantly share code, notes, and snippets.

@mheadd
Created June 21, 2010 11:16
Show Gist options
  • Save mheadd/446712 to your computer and use it in GitHub Desktop.
Save mheadd/446712 to your computer and use it in GitHub Desktop.
<?php
// Include Tropo classes.
require('TropoClasses.php');
// Include Limonade framework.
require('path/to/limonade/lib/limonade.php');
dispatch_post('/start', 'zip_start');
function zip_start() {
// Step 1. Create a new instance of the Session object, and get the channel information.
$session = new Session();
$from_info = $session->getFrom();
$channel = $from_info['channel'];
// Step 2. Create a new instance of the Tropo object.
$tropo = new Tropo();
// Step 3. Welcome prompt.
$tropo->say("Welcome to the Tropo PHP zip code example for $channel");
// Step 4. Set up options for zip code input.
$options = array("attempts" => 3, "bargein" => true, "choices" => "[5 DIGITS]", "name" => "zip", "timeout" => 5);
// Step 5. Ask the caller for input, pass in options.
$tropo->ask("Please enter your 5 digit zip code.", $options);
// Step 6. Tell Tropo what to do when the user has entered input. Enter your PostBin URL in the "next" array element.
$tropo->on(array("event" => "continue", "next" => "http://www.PostBin.org/xxxxxxx", "say" => "Please hold."));
// Step 7. Render the JSON for the Tropo WebAPI to consume.
return $tropo->RenderJson();
}
dispatch_post('/end', 'zip_end');
function zip_end() {
// Do something with the entered zip code.
}
dispatch_post('/error', 'zip_error');
function zip_error() {
// Tell the user an error has occurred.
}
// Run this sucker!
run();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment