📄 phpagi.php
字号:
* * @link http://www.voip-info.org/wiki-get+data * @param string $filename file to play. Do not include file extension. * @param integer $timeout milliseconds * @param integer $max_digits * @param char $escape_character * @return 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. */ function get_data($filename, $timeout=NULL, $max_digits=NULL, $escape_character=NULL) { return $this->evaluate(rtrim("GET DATA $filename $timeout $max_digits $escape_character")); } /** * Fetch the value of a variable. * * Does not work with global variables. Does not work with some variables that are generated by modules. * * @link http://www.voip-info.org/wiki-get+variable * @link http://www.voip-info.org/wiki-Asterisk+variables * @param string $variable name * @param boolean $get_value * @return array if $get_value is not set or set to false. * If $get_value is set to true, the value of the variable is returned. * See evaluate for return information. ['result'] is 0 if variable hasn't been set, 1 if it has. ['data'] holds the value. */ function get_variable($variable, $get_value = false) { $var = $this->evaluate("GET VARIABLE $variable"); if(isset($get_value) && $get_value){ return $var['data']; } else { return $var; } } /** * Hangup the specified channel. If no channel name is given, hang up the current channel. * * With power comes responsibility. Hanging up channels other than your own isn't something * that is done routinely. If you are not sure why you are doing so, then don't. * * @link http://www.voip-info.org/wiki-hangup * @example examples/dtmf.php Get DTMF tones from the user and say the digits * @example examples/input.php Get text input from the user and say it back * @example examples/ping.php Ping an IP address * * @param string $channel * @return array, see evaluate for return information. ['result'] is 1 on success, -1 on failure. */ function hangup($channel='') { return $this->evaluate("HANGUP $channel"); } /** * Does nothing. * * @link http://www.voip-info.org/wiki-noop * @return array, see evaluate for return information. */ function noop() { return $this->evaluate('NOOP'); } /** * 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. * * @link http://www.voip-info.org/wiki-receive+char * @param integer $timeout milliseconds * @return 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. */ function receive_char($timeout=-1) { return $this->evaluate("RECEIVE CHAR $timeout"); } /** * Record sound to a file until an acceptable DTMF digit is received or a specified amount of * time has passed. Optionally the file BEEP is played before recording begins. * * @link http://www.voip-info.org/wiki-record+file * @param string $file to record, without extension, often created in /var/lib/asterisk/sounds * @param string $format of the file. GSM and WAV are commonly used formats. MP3 is read-only and thus cannot be used. * @param string $escape_digits * @param integer $timeout is the maximum record time in milliseconds, or -1 for no timeout. * @param integer $offset to seek to without exceeding the end of the file. * @param boolean $beep * @param integer $silence number of seconds of silence allowed before the function returns despite the * lack of dtmf digits or reaching timeout. * @return array, see evaluate for return information. ['result'] is -1 on error, 0 on hangup, otherwise a decimal value of the * DTMF tone. Use chr() to convert to ASCII. */ function record_file($file, $format, $escape_digits='', $timeout=-1, $offset=NULL, $beep=false, $silence=NULL) { $cmd = trim("RECORD FILE $file $format \"$escape_digits\" $timeout $offset"); if($beep) $cmd .= ' BEEP'; if(!is_null($silence)) $cmd .= " s=$silence"; return $this->evaluate($cmd); } /** * Say the given digit string, returning early if any of the given DTMF escape digits are received on the channel. * * @link http://www.voip-info.org/wiki-say+digits * @param integer $digits * @param string $escape_digits * @return 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. */ function say_digits($digits, $escape_digits='') { if (PLAY_AUDIO){ return $this->evaluate("SAY DIGITS $digits \"$escape_digits\""); } } /** * Say the given number, returning early if any of the given DTMF escape digits are received on the channel. * * @link http://www.voip-info.org/wiki-say+number * @param integer $number * @param string $escape_digits * @return 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. */ function say_number($number, $escape_digits='') { if (PLAY_AUDIO){ return $this->evaluate("SAY NUMBER $number \"$escape_digits\""); } } /** * Say the given character string, returning early if any of the given DTMF escape digits are received on the channel. * * @link http://www.voip-info.org/wiki-say+phonetic * @param string $text * @param string $escape_digits * @return 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. */ function say_phonetic($text, $escape_digits='') { if (PLAY_AUDIO){ return $this->evaluate("SAY PHONETIC $text \"$escape_digits\""); } } /** * Say a given time, returning early if any of the given DTMF escape digits are received on the channel. * * @link http://www.voip-info.org/wiki-say+time * @param integer $time number of seconds elapsed since 00:00:00 on January 1, 1970, Coordinated Universal Time (UTC). * @param string $escape_digits * @return 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. */ function say_time($time=NULL, $escape_digits='') { if (PLAY_AUDIO){ if(is_null($time)) $time = time(); return $this->evaluate("SAY TIME $time \"$escape_digits\""); } } /** * Send the specified image on a channel. * * Most channels do not support the transmission of images. * * @link http://www.voip-info.org/wiki-send+image * @param string $image without extension, often in /var/lib/asterisk/images * @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if the image is sent or * channel does not support image transmission. */ function send_image($image) { return $this->evaluate("SEND IMAGE $image"); } /** * Send the given text to the connected channel. * * Most channels do not support transmission of text. * * @link http://www.voip-info.org/wiki-send+text * @param $text * @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if the text is sent or * channel does not support text transmission. */ function send_text($text) { return $this->evaluate("SEND TEXT \"$text\""); } /** * 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. * * @link http://www.voip-info.org/wiki-set+autohangup * @param integer $time until automatic hangup * @return array, see evaluate for return information. */ function set_autohangup($time=0) { return $this->evaluate("SET AUTOHANGUP $time"); } /** * Changes the caller ID of the current channel. * * @link http://www.voip-info.org/wiki-set+callerid * @param string $cid example: "John Smith"<1234567> * This command will let you take liberties with the <caller ID specification> 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. * @return array, see evaluate for return information. */ function set_callerid($cid) { return $this->evaluate("SET CALLERID $cid"); } /** * 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. * * @link http://www.voip-info.org/wiki-set+context * @param string $context * @return array, see evaluate for return information. */ function set_context($context) { return $this->evaluate("SET CONTEXT $context"); } /** * 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. * * @link http://www.voip-info.org/wiki-set+extension * @param string $extension * @return array, see evaluate for return information. */ function set_extension($extension) { return $this->evaluate("SET EXTENSION $extension"); } /** * Enable/Disable Music on hold generator. * * @link http://www.voip-info.org/wiki-set+music * @param boolean $enabled * @param string $class * @return array, see evaluate for return information. */ function set_music($enabled=true, $class='') { $enabled = ($enabled) ? 'ON' : 'OFF'; return $this->evaluate("SET MUSIC $enabled $class"); } /** * 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. * * @link http://www.voip-info.org/wiki-set+priority * @param integer $priority * @return array, see evaluate for return information. */ function set_priority($priority) { return $this->evaluate("SET PRIORITY $priority"); } /** * 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. * * @link http://www.voip-info.org/wiki-set+variable * @param string $variable is case sensitive * @param string $value * @return array, see evaluate for return information. */ function set_variable($variable, $value) { $value = str_replace("\n", '\n', addslashes($value)); return $this->evaluate("SET VARIABLE $variable \"$value\""); } /** * 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. * * @example examples/ping.php Ping an IP address * * @link http://www.voip-info.org/wiki-stream+file * @param string $filename without extension, often in /var/lib/asterisk/sounds * @param string $escape_digits * @param integer $offset * @return 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. */ function stream_file($filename, $escape_digits='', $offset=0) { if (PLAY_AUDIO){ return $this->evaluate("STREAM FILE $filename \"$escape_digits\" $offset"); } } /** * Enable or disable TDD transmission/reception on the current channel. * * @link http://www.voip-info.org/wiki-tdd+mode * @param string $setting can be on, off or mate * @return array, see evaluate for return information. ['result'] is 1 on sucess, 0 if the channel is not TDD capable. */ function tdd_mode($setting) { return $this->evaluate("TDD MODE $setting"); } /** * 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. * * @link http://www.voip-info.org/wiki-verbose * @param string $message * @param integer $level from 1 to 4 * @return array, see evaluate for return information. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -