Skip to content
mheadd edited this page Sep 14, 2010 · 8 revisions

An object representation of the JSON that is delivered from the Tropo WebAPI at the start of a new session.
Use this object to determine what channel is being used to access the application.

	
// Create a new Tropo Session Object and determine the channel in use.
$session = new Session();

// Get the TO information from the Tropo Session Object 
// (i.e., who is calling, on what network, using what channel, etc.)
$to = $session->getTo();
$channel = $to['channel'];
	
// Set the greeting prompt according to the channel.
if($channel == 'PSTN') {
	$greetingText = "Welcome to my Phone application. ";
}
else {
	$greetingText = "Welcome to my Text application. ";
}

....

$session = new Session();

// Get the GUID representing the unique session identifier.
$id = $session->getId();

// Get the user account ID that started this session.
$accountID = $session->getAccountID();

// Get the time that the session was started.
$timeStamp = $session->getTimeStamp();

// Get the type of user that is on the other end of the session. 
// It can be set to 'HUMAN', 'MACHINE' or 'FAX'.
$userType = $session->getUserType();

// When the channel is of a type "TEXT", this method returns the initial text from the client.
$initialText = $session->getInitialText();

// Gets information on who the interaction is directed to.
$to = $session->getTo();

// Gets information on who the interaction is from.
$from = $session->getFrom();

//  the Session Initiation Protocol (SIP) Headers for the current session.
$headers = $session->getHeaders();

// Get the parameters sent in with the session invocation.
// Typically used on token initated requests.
$allParameters = $session->getParameters();

$foo = $session->getParameters('foo');

Clone this wiki locally