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(); }
function demo_error() { $tropo = new Tropo(); $tropo->say("Please try your request again later."); $tropo->hangup(); return $tropo->renderJSON(); }
function app_continue() { $tropo = new Tropo(); @($result = new Result()); $userType = $result->getUserType(); $tropo->say("You are a {$userType}"); $tropo->RenderJson(); }
public function voice_continue() { $this->set_output_mode(MY_Controller::OUTPUT_NORMAL); $tropo = new Tropo(); @($result = new Result()); $answer = $result->getValue(); $tropo->say("You said " . $answer); $tropo->RenderJson(); }
function app_error() { $tropo = new Tropo(); $tropo->say("Something has gone wrong, please call back."); $tropo->hangup(); return $tropo->RenderJson(); }
<?php require 'tropo.class.php'; error_reporting(0); $tropo = new Tropo(); $session = new Session(); $from = $session->getFrom(); $callerID = $from["id"]; $tropo->say("You are about to enter the conference"); $tropo->conference(null, array("id" => "1234", "name" => "joinleave", "joinPrompt" => "{$callerID} has entered the conference", "leavePrompt" => "{$callerID} has left the conference", "voice" => "Kate")); $tropo->RenderJson();
function zip_error() { // Step 1. Create a new instance of the Tropo object. $tropo = new Tropo(); // Step 2. This is the last thing the user will be told before the session ends. $tropo->say("Please try your request again later."); // Step 3. End the session. $tropo->hangup(); // Step 4. Render the JSON for the Tropo WebAPI to consume. return $tropo->renderJSON(); }
$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; $venues = array();
<?php /** * A sample application that demonstrates the use of the TropoPHP package. * @copyright 2010 Mark J. Headd (http://www.voiceingov.org) */ // Include Tropo classes. require 'tropo.class.php'; $tropo = new Tropo(); $tropo->say("Hello World!"); $tropo->renderJson();
<?php include_once 'tropo.class.php'; $token = 'your token here'; $number = 'the number you would like to dial'; $tropo = new Tropo(); try { $session = new Session(); if ($session->getParams("action") == "create") { $tropo->call($session->getParams("dial")); $tropo->say('This is an outbound call.'); } else { $tropo->say('Thank you for calling us.'); } $tropo->renderJSON(); } catch (Exception $e) { if ($e->getCode() == '1') { // The session object threw an exception, so this file wasn't // loaded as part of a Tropo session. Launch a Tropo session. if ($tropo->createSession($token, array('dial' => $number))) { print 'Call launched to ' . $number; } } }
<?php //this example accepts parameters passed to it from an outside REST request (such as a curl app) - //it extracts the values of the passed parameters and uses it to send, in this case, an outbound text use Tropo\Action\Session; require 'tropo.class.php'; //brings in the Tropo library $session = new Session(); $to = "+" . $session->getParameters("numbertodial"); $name = $session->getParameters("customername"); $msg = $session->getParameters("msg"); //extracts the contents of the passed parameters and assigns them as variables for later use $tropo = new Tropo(); $tropo->call($to, array('network' => 'SMS')); $tropo->say("OMG " . $name . ", " . $msg . "!"); //actually creates the call, passed the "to" value and then adds in the other variables for the message return $tropo->RenderJson(); //defines the response to Tropo in JSON ?>
// Include the library require 'tropo.class.php'; try { // If there is not a session object in the POST body, // then this isn't a new session. Tropo will throw // an exception, so check for that. $session = new Session(); } catch (TropoException $e) { // This is a normal case, so we don't really need to // do anything if we catch this. } $caller = $session->getFrom(); $tropo = new Tropo(); // $caller now has a hash containing the keys: id, name, channel, and network $tropo->say("Your phone number is " . $caller['id']); $called = $session->getTo(); // $called now has a hash containing the keys: id, name, channel, and network $tropo->say("You called " . $called['id'] . " but you probably already knew that."); if ($called['channel'] == "TEXT") { // This is a text message $tropo->say("You contacted me via text."); // The first text of the session is going to be queued and applied to the first // ask statement you include... $tropo->ask("This will catch the first text", array('choices' => '[ANY]')); // ... or, you can grab that first text like this straight from the session. $messsage = $session->getInitialText(); $tropo->say("You said " . $message); } else { // This is a phone call $tropo->say("Awww. How nice. You cared enough to call.");
protected function _send_reply_message() { $tropo = new Tropo(); $tropo->call($this->_session->from_phone_number, array('network' => 'SMS')); $tropo->say($this->_session->message); $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();