function app_choice()
{
    // Accessing the result object
    $result = new Result();
    $choice = $result->getValue();
    // Create a new instance of the Tropo object.
    $tropo = new Tropo();
    // Provide a prompt based on the value
    if ($choice == "1") {
        $tropo->say("You picked Lord of the Rings.  Did you know Gandalf is also Mag knee toe?  Weird.");
    }
    if ($choice == "2") {
        $tropo->say("You picked the original Star Wars.  I hear Leonard Nimoy was awe some in those.");
    }
    if ($choice == "3") {
        $tropo->say("You picked the Star Wars prequels.  Stop calling this number, Mr. Lucas, we know it's you.");
    }
    if ($choice == "4") {
        $tropo->say("You picked the Matrix. Dude, woe.");
    }
    // Tell Tropo what to do next. This redirects to the instructions under dispatch_post('/hangup', 'app_hangup').
    $tropo->on(array("event" => "continue", "next" => "favorite-movie-webapi.php?uri=hangup"));
    // Tell Tropo what to do if there's an problem, like a timeout. This redirects to the instructions under dispatch_post('/incomplete', 'app_incomplete').
    $tropo->on(array("event" => "incomplete", "next" => "favorite-movie-webapi.php?uri=incomplete"));
    // Render the JSON for the Tropo WebAPI to consume.
    return $tropo->RenderJson();
}
Exemplo n.º 2
0
function demo_start()
{
    $session = new Session();
    $from_info = $session->getFrom();
    $network = $from_info[3];
    $tropo = new Tropo();
    $tropo->say("Welcome to the Tropo PHP weather demo for {$network}.");
    $options = array("attempts" => 3, "bargein" => true, "choices" => "[5 DIGITS]", "name" => "zip", "timeout" => 5);
    $tropo->ask("Please enter your 5 digit zip code.", $options);
    $tropo->on(array("event" => "continue", "next" => "WeatherDemo.php?uri=end", "say" => "Please hold."));
    $tropo->on(array("event" => "error", "next" => "WeatherDemo.php?uri=error", "say" => "You seem to be having trouble."));
    return $tropo->RenderJson();
}
function app_start()
{
    $tropo = new Tropo();
    $tropo->call("+14071234321", array("machineDetection" => "This is just a test to see if you are a human or a machine. PLease hold while we determine. Almost finished. Thank you!", "voice" => "Kate"));
    $tropo->on(array("event" => "continue", "next" => "your_app.php?uri=continue"));
    $tropo->RenderJson();
}
function conference()
{
    global $voice;
    $tropo = new Tropo();
    $tropo->setVoice($voice);
    $result = new Result();
    $conference = $result->getValue();
    $tropo->say('<speak>Conference ID <say-as interpret-as=\'vxml:digits\'>' . $conference . '</say-as> accepted.</speak>');
    $tropo->say('You will now be placed into the conference. Please announce yourself. To exit the conference without disconnecting, press pound.');
    $tropo->conference($conference, array('id' => $conference, 'terminator' => '#'));
    $tropo->say('You have left the conference.');
    $tropo->on(array("event" => "continue", "next" => "restart"));
    $tropo->RenderJson();
}
Exemplo n.º 5
0
 public function voice($number = '', $initial_text = '')
 {
     $this->set_output_mode(MY_Controller::OUTPUT_NORMAL);
     $session = new Session();
     $phone_number = $session->getParameters('phone_number');
     $message = $session->getParameters('message');
     $tropo = new Tropo();
     $tropo->call("sip:{$phone_number}@shims.starhub.net.sg");
     $tropo->wait(1000);
     $tropo->say($message);
     $caller = $session->getFrom();
     $called = $session->getTo();
     $tropo->say('Your number is ' . $caller['id']);
     //$tropo->say('This is via '.$called['channel']);
     $tropo->ask('Press 1 to hangup or 2 to continue', array('choices' => "1,2", 'name' => 'digit', 'timeout' => 60));
     $tropo->on(array('event' => 'continue', 'next' => 'voice_continue'));
     $tropo->RenderJson();
 }
Exemplo n.º 6
0
 */
$fsUser = '******';
$fsPass = '******';
require 'TropoClasses.php';
$voice = 'allison';
// set the base URL for the app
$base = !empty($_SERVER['HTTPS']) ? "https://" : "http://";
$base .= $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
$tropo = new Tropo();
$tropo->voice = 'allison';
// set a default action
$action = isset($_GET['event']) ? $_GET['event'] : '/';
if ($action == '/') {
    // This is a new session, not an event.
    // Set up the event that fires when the next response is sent from Tropo
    $tropo->on(array('event' => 'continue', 'next' => $base . '?event=checkin'));
    $tropo->say('Welcome to the Four Square check in I V R.');
    // Get last FS checkin
    $history = getapi('history', null, 1);
    if (!is_array($history['checkins'])) {
        // Since we have no data, foursquare API must be having issues. Hang up.
        $tropo->say('Could not reach the Four Square API. Try again later.');
        print $tropo;
        die;
    }
    // What is the geolocation of my last checkin?
    $lat = $history['checkins'][0]['venue']['geolat'];
    $long = $history['checkins'][0]['venue']['geolong'];
    // Find venues nearby where I've checked in recently.
    $nearby = getapi('venues', array('geolat' => $lat, 'geolong' => $long), 9);
    $dtmf = 1;
<?php

// Include required classes.
require 'classes/tropo.class.php';
require 'classes/sag/sag.php';
// Grab the raw JSON sent from Tropo.
$json = file_get_contents("php://input");
// Create a new Session object and obtain the session ID value.
$session = new Session($json);
$session_id = $session->getId();
// Insert the Session object into a CouchDB database called sessions.
try {
    $sag = new Sag();
    $sag->setDatabase("sessions");
    $sag->put($session_id, $json);
} catch (SagCouchException $ex) {
    die("*** " . $ex->getMessage() . " ***");
}
// Create a new Tropo object.
$tropo = new Tropo();
// Set options for an Ask.
$options = array("attempts" => 20, "bargein" => true, "choices" => "[5 DIGITS]", "name" => "zip", "timeout" => 5, "allowSignals" => array("tooLong", "farTooLong"));
$tropo->ask("Please enter your 5 digit zip code.", $options);
// Set event handlers
$tropo->on(array("event" => "continue", "next" => "get_zip_code.php?uri=end", "say" => "Please hold."));
$tropo->on(array("event" => "tooLong", "next" => "get_zip_code.php?uri=end&tooLong=true", "say" => "Please hold on."));
$tropo->on(array("event" => "farTooLong", "next" => "get_zip_code.php?uri=end&farTooLong=true", "say" => "Please hold on for dear life."));
// Render JSON for Tropo to consume.
$tropo->renderJSON();
<?php

require 'tropo.class.php';
error_reporting(0);
$tropo = new Tropo();
//Send a whisper array with all of the functions
$whisper = array();
//The next method will be an ask
$choices = new Choices("1", "dtmf");
$a = new Ask(1, true, $choices, NULL, "foo", true, "Press one to accept the call or any other number to decline.", 30, NULL, NULL, NULL, NULL, NULL, 0.01, NULL);
$ask = array("ask" => $a);
//push the ask to the whisper array
array_push($whisper, $ask);
//The first method will be a say
$say = array("say" => new Say("You are now being connected to the call."));
//Push the say to the whisper array
array_push($whisper, $say);
$tropo->say("please hold while you are transferred");
//Create the connect whisper on event for the transfer with a ring event
$on = array("event" => "connect", "whisper" => $whisper, "ring" => "http://www.phono.com/audio/holdmusic.mp3");
//Create the connect whisper on event for the transfer without a ring event
$on = array("event" => "connect", "whisper" => $whisper);
$options = array('on' => $on, 'from' => '14071234321');
//use the connect whisper in the transfer
$tropo->transfer("+14071234321", $options);
$tropo->on(array("event" => "incomplete", "next" => "hangup.php", "say" => "You have opted to not accept this call. Goodbye!"));
echo $tropo->RenderJson();