FreenetIS
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Public Attributes | List of all members
AGI Class Reference

Public Member Functions

 AGI ($config=NULL, $optconfig=array())
 Constructor.
 answer ()
 channel_status ($channel='')
 Get the status of the specified channel.
 database_del ($family, $key)
 Deletes an entry in the Asterisk database for a given family and key.
 database_deltree ($family, $keytree='')
 Deletes a family or specific keytree within a family in the Asterisk database.
 database_get ($family, $key)
 Retrieves an entry in the Asterisk database for a given family and key.
 database_put ($family, $key, $value)
 Adds or updates an entry in the Asterisk database for a given family, key, and value.
 exec ($application, $options)
 Executes the specified Asterisk application with given options.
 get_data ($filename, $timeout=NULL, $max_digits=NULL)
 get_variable ($variable)
 Fetch the value of a variable.
 hangup ($channel='')
 noop ()
 Does nothing.
 receive_char ($timeout=-1)
 Receive a character of text from a connected channel.
 record_file ($file, $format, $escape_digits='', $timeout=-1, $offset=NULL, $beep=false, $silence=NULL)
 Record sound to a file until an acceptable DTMF digit is received or a specified amount of time has passed.
 say_digits ($digits, $escape_digits='')
 Say the given digit string, returning early if any of the given DTMF escape digits are received on the channel.
 say_number ($number, $escape_digits='')
 Say the given number, returning early if any of the given DTMF escape digits are received on the channel.
 say_phonetic ($text, $escape_digits='')
 Say the given character string, returning early if any of the given DTMF escape digits are received on the channel.
 say_time ($time=NULL, $escape_digits='')
 Say a given time, returning early if any of the given DTMF escape digits are received on the channel.
 send_image ($image)
 Send the specified image on a channel.
 send_text ($text)
 Send the given text to the connected channel.
 set_autohangup ($time=0)
 Cause the channel to automatically hangup at $time seconds in the future.
 set_callerid ($cid)
 Changes the caller ID of the current channel.
 set_context ($context)
 Sets the context for continuation upon exiting the application.
 set_extension ($extension)
 Set the extension to be used for continuation upon exiting the application.
 set_music ($enabled=true, $class='')
 Enable/Disable Music on hold generator.
 set_priority ($priority)
 Set the priority to be used for continuation upon exiting the application.
 set_variable ($variable, $value)
 Sets a variable to the specified value.
 stream_file ($filename, $escape_digits='', $offset=0)
 tdd_mode ($setting)
 Enable or disable TDD transmission/reception on the current channel.
 verbose ($message, $level=1)
 Sends $message to the Asterisk console via the 'verbose' message system.
 wait_for_digit ($timeout=-1)
 Waits up to $timeout milliseconds for channel to receive a DTMF digit.
 exec_absolutetimeout ($seconds=0)
 Set absolute maximum time of call.
 exec_agi ($command, $args)
 Executes an AGI compliant application.
 exec_setlanguage ($language='en')
 Set Language.
 exec_enumlookup ($exten)
 Do ENUM Lookup.
 exec_dial ($type, $identifier, $timeout=NULL, $options=NULL, $url=NULL)
 Dial.
 exec_goto ($a, $b=NULL, $c=NULL)
 Goto.
 fastpass_say_digits (&$buffer, $digits, $escape_digits='')
 Say the given digit string, returning early if any of the given DTMF escape digits are received on the channel.
 fastpass_say_number (&$buffer, $number, $escape_digits='')
 Say the given number, returning early if any of the given DTMF escape digits are received on the channel.
 fastpass_say_phonetic (&$buffer, $text, $escape_digits='')
 Say the given character string, returning early if any of the given DTMF escape digits are received on the channel.
 fastpass_say_time (&$buffer, $time=NULL, $escape_digits='')
 Say a given time, returning early if any of the given DTMF escape digits are received on the channel.
 fastpass_stream_file (&$buffer, $filename, $escape_digits='', $offset=0)
 Play the given audio file, allowing playback to be interrupted by a DTMF digit.
 fastpass_text2wav (&$buffer, $text, $escape_digits='', $frequency=8000)
 Use festival to read text.
 fastpass_swift (&$buffer, $text, $escape_digits='', $frequency=8000, $voice=NULL)
 Use Cepstral Swift to read text.
 fastpass_say_punctuation (&$buffer, $text, $escape_digits='', $frequency=8000)
 Say Puncutation in a string.
 fastpass_get_data (&$buffer, $filename, $timeout=NULL, $max_digits=NULL)
 Plays the given file and receives DTMF data.
 menu ($choices, $timeout=2000)
 Menu.
 parse_callerid ($callerid=NULL)
 text2wav ($text, $escape_digits='', $frequency=8000)
 swift ($text, $escape_digits='', $frequency=8000, $voice=NULL)
 Use Cepstral Swift to read text.
 text_input ($mode='NUMERIC')
 say_punctuation ($text, $escape_digits='', $frequency=8000)
 Say Puncutation in a string.
new_AsteriskManager ()
 Create a new AsteriskManager.
 evaluate ($command)
 Evaluate an AGI command.
 conlog ($str, $vbl=1)
 which ($cmd, $checkpath=NULL)
 Find an execuable in the path.
 make_folder ($folder, $perms=0755)
 Make a folder recursively.

Public Attributes

 $request
 $config
 $asmanager
 $in = NULL
 Input Stream.
 $out = NULL
 Output Stream.
 $audio = NULL
 Audio Stream.

Member Function Documentation

AGI::AGI (   $config = NULL,
  $optconfig = array() 
)

Constructor.

Parameters
string$configis the name of the config file to parse
array$optconfigis an array of configuration vars and vals, stuffed into $this->config['phpagi']
AGI::channel_status (   $channel = '')

Get the status of the specified channel.

If no channel name is specified, return the status of the current channel.

string $channel array, see evaluate for return information. ['data'] contains description.

AGI::database_del (   $family,
  $key 
)
AGI::database_deltree (   $family,
  $keytree = '' 
)

Deletes a family or specific keytree within a family in the Asterisk database.

string $family string $keytree array, see evaluate for return information. ['result'] is 1 on sucess, 0 otherwise.

AGI::database_get (   $family,
  $key 
)
AGI::database_put (   $family,
  $key,
  $value 
)

Adds or updates an entry in the Asterisk database for a given family, key, and value.

Parameters
string$family
string$key
string$value
Returns
array, see evaluate for return information. ['result'] is 1 on sucess, 0 otherwise
AGI::evaluate (   $command)

Evaluate an AGI command.

private

Parameters
string$command
Returns
array ('code'=>$code, 'result'=>$result, 'data'=>$data)
AGI::exec (   $application,
  $options 
)

Executes the specified Asterisk application with given options.

http://www.voip-info.org/wiki-Asterisk+-+documentation+of+application+commands string $application mixed $options array, see evaluate for return information. ['result'] is whatever the application returns, or -2 on failure to find application

AGI::exec_absolutetimeout (   $seconds = 0)

Set absolute maximum time of call.

Note that the timeout is set from the current time forward, not counting the number of seconds the call has already been up. Each time you call AbsoluteTimeout(), all previous absolute timeouts are cancelled. Will return the call to the T extension so that you can playback an explanatory note to the calling party (the called party will not hear that)

http://www.dynx.net/ASTERISK/AGI/ccard/agi-ccard.agi $seconds allowed, 0 disables timeout array, see evaluate for return information.

AGI::exec_agi (   $command,
  $args 
)

Executes an AGI compliant application.

Parameters
string$command
Returns
array, see evaluate for return information. ['result'] is -1 on hangup or if application requested hangup, or 0 on non-hangup exit.
Parameters
string$args
AGI::exec_dial (   $type,
  $identifier,
  $timeout = NULL,
  $options = NULL,
  $url = NULL 
)

Dial.

Dial takes input from ${VXML_URL} to send XML Url to Cisco 7960 Dial takes input from ${ALERT_INFO} to set ring cadence for Cisco phones Dial returns ${CAUSECODE}: If the dial failed, this is the errormessage. Dial returns ${DIALSTATUS}: Text code returning status of last dial attempt.

string $type string $identifier integer $timeout string $options string $url array, see evaluate for return information.

AGI::exec_enumlookup (   $exten)

Do ENUM Lookup.

Note: to retrieve the result, use get_variable('ENUM');

Parameters
$exten
Returns
array, see evaluate for return information.
AGI::exec_goto (   $a,
  $b = NULL,
  $c = NULL 
)

Goto.

This function takes three arguments: context,extension, and priority, but the leading arguments are optional, not the trailing arguments. Thuse goto($z) sets the priority to $z.

Parameters
string$a
string$b,;
string$c,;
Returns
array, see evaluate for return information.
AGI::exec_setlanguage (   $language = 'en')

Set Language.

Parameters
string$languagecode
Returns
array, see evaluate for return information.
AGI::fastpass_get_data ( $buffer,
  $filename,
  $timeout = NULL,
  $max_digits = NULL 
)

Plays the given file and receives DTMF data.

Return early if $buffer is adequate for request.

This is similar to STREAM FILE, but this command can accept and return many DTMF digits, while STREAM FILE returns immediately after the first DTMF digit is detected.

Asterisk looks for the file to play in /var/lib/asterisk/sounds by default.

If the user doesn't press any keys when the message plays, there is $timeout milliseconds of silence then the command ends.

The user has the opportunity to press a key at any time during the message or the post-message silence. If the user presses a key while the message is playing, the message stops playing. When the first key is pressed a timer starts counting for $timeout milliseconds. Every time the user presses another key the timer is restarted. The command ends when the counter goes to zero or the maximum number of digits is entered, whichever happens first.

If you don't specify a time out then a default timeout of 2000 is used following a pressed digit. If no digits are pressed then 6 seconds of silence follow the message.

If you don't specify $max_digits then the user can enter as many digits as they want.

Pressing the # key has the same effect as the timer running out: the command ends and any previously keyed digits are returned. A side effect of this is that there is no way to read a # key using this command.

string $buffer string $filename file to play. Do not include file extension. integer $timeout milliseconds integer $max_digits array, see evaluate for return information. ['result'] holds the digits and ['data'] holds the timeout if present. This differs from other commands with return DTMF as numbers representing ASCII characters.

AGI::fastpass_say_digits ( $buffer,
  $digits,
  $escape_digits = '' 
)
AGI::fastpass_say_number ( $buffer,
  $number,
  $escape_digits = '' 
)
AGI::fastpass_say_phonetic ( $buffer,
  $text,
  $escape_digits = '' 
)
AGI::fastpass_say_punctuation ( $buffer,
  $text,
  $escape_digits = '',
  $frequency = 8000 
)

Say Puncutation in a string.

Return early if $buffer is adequate for request.

Parameters
string$buffer
string$text
string$escape_digits
integer$frequency
Returns
array, see evaluate for return information.
AGI::fastpass_say_time ( $buffer,
  $time = NULL,
  $escape_digits = '' 
)
AGI::fastpass_stream_file ( $buffer,
  $filename,
  $escape_digits = '',
  $offset = 0 
)

Play the given audio file, allowing playback to be interrupted by a DTMF digit.

This command is similar to the GET DATA command but this command returns after the first DTMF digit has been pressed while GET DATA can accumulated any number of digits before returning. Return early if $buffer is adequate for request.

string $buffer string $filename without extension, often in /var/lib/asterisk/sounds string $escape_digits integer $offset array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no digit received, otherwise a decimal value of the DTMF tone. Use chr() to convert to ASCII.

AGI::fastpass_swift ( $buffer,
  $text,
  $escape_digits = '',
  $frequency = 8000,
  $voice = NULL 
)

Use Cepstral Swift to read text.

Return early if $buffer is adequate for request.

string $buffer string $text string $escape_digits integer $frequency array, see evaluate for return information.

AGI::fastpass_text2wav ( $buffer,
  $text,
  $escape_digits = '',
  $frequency = 8000 
)

Use festival to read text.

Return early if $buffer is adequate for request.

string $buffer string $text string $escape_digits integer $frequency array, see evaluate for return information.

AGI::get_variable (   $variable)

Fetch the value of a variable.

Does not work with global variables. Does not work with some variables that are generated by modules.

http://www.voip-info.org/wiki-Asterisk+variables string $variable name array, see evaluate for return information. ['result'] is 0 if variable hasn't been set, 1 if it has. ['data'] holds the value.

AGI::make_folder (   $folder,
  $perms = 0755 
)

Make a folder recursively.

private

Parameters
string$folder
integer$perms
AGI::menu (   $choices,
  $timeout = 2000 
)

Menu.

This function presents the user with a menu and reads the response

Parameters
array$choiceshas the following structure: array('1'=>'Press 1 for this', // festival reads if prompt starts with * '2'=>'some-gsm-without-extension', ''=>'*Press star for help');
Returns
mixed key pressed on sucess, -1 on failure
AGI::noop ( )
AGI::receive_char (   $timeout = -1)

Receive a character of text from a connected channel.

Waits up to $timeout milliseconds for a character to arrive, or infinitely if $timeout is zero.

integer $timeout milliseconds array, see evaluate for return information. ['result'] is 0 on timeout or not supported, -1 on failure. Otherwise it is the decimal value of the DTMF tone. Use chr() to convert to ASCII.

AGI::record_file (   $file,
  $format,
  $escape_digits = '',
  $timeout = -1,
  $offset = NULL,
  $beep = false,
  $silence = NULL 
)
AGI::say_digits (   $digits,
  $escape_digits = '' 
)
AGI::say_number (   $number,
  $escape_digits = '' 
)
AGI::say_phonetic (   $text,
  $escape_digits = '' 
)
AGI::say_punctuation (   $text,
  $escape_digits = '',
  $frequency = 8000 
)

Say Puncutation in a string.

Parameters
string$text
string$escape_digits
integer$frequency
Returns
array, see evaluate for return information.
AGI::say_time (   $time = NULL,
  $escape_digits = '' 
)
AGI::send_image (   $image)
AGI::send_text (   $text)
AGI::set_autohangup (   $time = 0)

Cause the channel to automatically hangup at $time seconds in the future.

If $time is 0 then the autohangup feature is disabled on this channel.

If the channel is hungup prior to $time seconds, this setting has no effect.

integer $time until automatic hangup array, see evaluate for return information.

AGI::set_callerid (   $cid)

Changes the caller ID of the current channel.

string $cid example: "John Smith"<1234567> This command will let you take liberties with the but the format shown in the example above works well: the name enclosed in double quotes followed immediately by the number inside angle brackets. If there is no name then you can omit it. If the name contains no spaces you can omit the double quotes around it. The number must follow the name immediately; don't put a space between them. The angle brackets around the number are necessary; if you omit them the number will be considered to be part of the name.

Returns
array, see evaluate for return information.
AGI::set_context (   $context)

Sets the context for continuation upon exiting the application.

Setting the context does NOT automatically reset the extension and the priority; if you want to start at the top of the new context you should set extension and priority yourself.

If you specify a non-existent context you receive no error indication (['result'] is still 0) but you do get a warning message on the Asterisk console.

string $context array, see evaluate for return information.

AGI::set_extension (   $extension)

Set the extension to be used for continuation upon exiting the application.

Setting the extension does NOT automatically reset the priority. If you want to start with the first priority of the extension you should set the priority yourself.

If you specify a non-existent extension you receive no error indication (['result'] is still 0) but you do get a warning message on the Asterisk console.

string $extension array, see evaluate for return information.

AGI::set_music (   $enabled = true,
  $class = '' 
)
AGI::set_priority (   $priority)

Set the priority to be used for continuation upon exiting the application.

If you specify a non-existent priority you receive no error indication (['result'] is still 0) and no warning is issued on the Asterisk console.

integer $priority array, see evaluate for return information.

AGI::set_variable (   $variable,
  $value 
)

Sets a variable to the specified value.

The variables so created can later be used by later using ${<variablename>} in the dialplan.

These variables live in the channel Asterisk creates when you pickup a phone and as such they are both local and temporary. Variables created in one channel can not be accessed by another channel. When you hang up the phone, the channel is deleted and any variables in that channel are deleted as well.

string $variable is case sensitive string $value array, see evaluate for return information.

AGI::swift (   $text,
  $escape_digits = '',
  $frequency = 8000,
  $voice = NULL 
)
AGI::tdd_mode (   $setting)
AGI::verbose (   $message,
  $level = 1 
)

Sends $message to the Asterisk console via the 'verbose' message system.

If the Asterisk verbosity level is $level or greater, send $message to the console.

The Asterisk verbosity system works as follows. The Asterisk user gets to set the desired verbosity at startup time or later using the console 'set verbose' command. Messages are displayed on the console if their verbose level is less than or equal to desired verbosity set by the user. More important messages should have a low verbose level; less important messages should have a high verbose level.

string $message integer $level from 1 to 4 array, see evaluate for return information.

AGI::wait_for_digit (   $timeout = -1)
AGI::which (   $cmd,
  $checkpath = NULL 
)

Find an execuable in the path.

private

Parameters
string$cmdcommand to find
string$checkpathpath to check
Returns
string the path to the command

Member Data Documentation

AGI::$audio = NULL

Audio Stream.

public

AGI::$in = NULL

Input Stream.

private

AGI::$out = NULL

Output Stream.

private


The documentation for this class was generated from the following file: