PHP Interface PAGI\Client\IClient

PHP Version 5
Author: Marcelo Gornstein ([email protected])
Show file Open project: marcelog/pagi Interface Usage Examples

Public Methods

Method Description
amd ( string[] $options ) : AmdResult Runs the AMD() application. For a complete list of options see: https://wiki.asterisk.org/wiki/display/AST/Application_AMD
answer ( ) : void Answers the current channel. Uses agi command "ANSWER".
channelStatus ( string $channel = '' ) : integer Retrieves channel status. Uses agi command "CHANNEL STATUS"
consoleLog ( string $msg ) : void Logs to asterisk console. Uses agi command "VERBOSE".
createNode ( string $name ) : Node Convenient method to create a node.
createNodeController ( string $name ) : NodeController Creates a new node controller.
databaseDel ( string $family, string $key ) : void Deletes an entry in the Asterisk database for a given family and key.
databaseDeltree ( string $family, string $key = false ) : void Deletes a family or specific keytree withing a family in the Asterisk database.
databaseGet ( string $family, string $key ) : string Retrieves an entry in the Asterisk database for a given family and key.
databasePut ( string $family, string $key, string $value ) : void Adds or updates an entry in the Asterisk database for a given family, key, and value.
dial ( string $channel, array $options = [] ) : DialResult Tries to dial the given channel.
exec ( string $application, array $options = [] ) : ExecResult Executes an application. Uses agi command "EXEC".
faxReceive ( string $tiffFile ) : FaxResult Receives a fax.
faxSend ( string $tiffFile ) : FaxResult Sends a fax.
getAsteriskLogger ( ) : PAGI\Logger\Asterisk\IAsteriskLogger Returns an asterisk logger facade.
getCDR ( ) : PAGI\CDR\ICDR Returns a cdr facade.
getCallerId ( ) : ICallerID Returns a caller id facade.
getChannelVariables ( ) : PAGI\ChannelVariables\IChannelVariables Returns an instance of ChannelVariables to access agi variables.
getData ( string $file, integer $maxTime, string $maxDigits ) : PlayResult Reads input from user. Uses agi command "GET DATA".
getFullVariable ( string $name, string $channel = false ) : string Returns a variable value. Uses agi command "GET FULL VARIABLE". False if variable is not set.
getOption ( string $file, string $escapeDigits, integer $maxTime ) : PlayResult Reads input from user. Uses agi command "GET OPTION".
getVariable ( string $name ) : string Returns a variable value. Uses agi command "GET VARIABLE". False if variable is not set.
hangup ( ) : void Hangups the current channel. Uses agi command "HANGUP".
indicateBusy ( integer $timeout ) : ExecResult Indicates busy and waits for hangup. Does not play a busy tone.
indicateCongestion ( integer $timeout ) : ExecResult Indicates congestion and waits for hangup. Does not play a busy tone.
indicateProgress ( ) : ExecResult Indicates progress of a call, starting early audio.
log ( string $msg, string $priority = 'NOTICE' ) : void Logs to asterisk logger. Uses application LOG.
playBusyTone ( ) : ExecResult Plays "Busy" tone, defined in indications.conf
playCongestionTone ( ) : ExecResult Plays "Congestion" tone, defined in indications.conf
playCustomTones ( array $frequencies ) : ExecResult Plays a customized frequency tone.
playDialTone ( ) : ExecResult Plays "Dial" tone, defined in indications.conf
playTone ( string $tone ) : ExecResult Plays a tone defined in indications.conf.
record ( string $file, string $format, string $escapeDigits, integer $maxRecordTime, integer $silence = false ) : PAGI\Client\Result\RecordResult Record to a file until are received as dtmf.
sayAlpha ( string $what, string $escapeDigits = '' ) : PlayResult Say a given character string, returning early if any of the given DTMF digits are received on the channel. Uses agi command "SAY PHONETIC".
sayDate ( integer $time, string $escapeDigits = '' ) : PlayResult Say a given date, returning early if any of the given DTMF digits are received on the channel. Uses agi command "SAY DATE".
sayDateTime ( integer $time, string $format, string $escapeDigits = '' ) : PlayResult Say a given date and time, returning early if any of the given DTMF digits are received on the channel. Uses agi command "SAY DATETIME".
sayDigits ( string $digits, string $escapeDigits = '' ) : PlayResult Says digits. Uses agi command "SAY DIGITS".
sayNumber ( string $digits, string $escapeDigits = '' ) : PlayResult Says a number. Uses agi command "SAY NUMBER".
sayPhonetic ( string $what, string $escapeDigits = '' ) : PlayResult Say a given character string with phonetics, returning early if any of the given DTMF digits are received on the channel.
sayTime ( integer $time, string $escapeDigits = '' ) : PlayResult Says time. Uses agi command "SAY TIME".
sendImage ( string $filename ) : void Sends the given image on a channel. Uses agi command "SEND IMAGE".
sendText ( string $text ) : void Sends the given text on a channel. Uses agi command "SEND TEXT".
setAutoHangup ( integer $time ) : void Cause the channel to automatically hangup at
setCallerId ( string $name, string $number ) : void Changes the callerid of the current channel. Uses agi command "SET CALLERID"
setContext ( string $context ) : void Changes the context for continuation upon exiting the application.
setExtension ( string $extension ) : void Changes the extension for continuation upon exiting the application.
setLogger ( Psr\Log\LoggerInterface $logger ) : void Sets the logger implementation.
setMusic ( boolean $enable, string $class = false ) : void Enables/Disables the music on hold generator. Uses agi command "SET MUSIC".
setPriority ( string $priority ) : void Changes the priority for continuation upon exiting the application.
setVariable ( string $name, string $value ) : void Sets a variable. Uses agi command "SET VARIABLE".
sipHeaderAdd ( string $name, string $value ) : ExecResult Adds a SIP header to the first invite message in a dial command.
sipHeaderRemove ( string $name ) : ExecResult Removes a header previously added with sipHeaderAdd.
stopPlayingTones ( ) : ExecResult Stop playing current played tones.
streamFile ( string $file, string $escapeDigits = '' ) : PlayResult Plays a file, can be interrupted by escapeDigits.
waitDigit ( integer $timeout ) : DigitReadResult Waits up to milliseconds for channel to receive a DTMF digit.

Method Details

amd() public method

Runs the AMD() application. For a complete list of options see: https://wiki.asterisk.org/wiki/display/AST/Application_AMD
public amd ( string[] $options ) : AmdResult
$options string[]
return PAGI\Client\Result\AmdResult

answer() public method

Answers the current channel. Uses agi command "ANSWER".
public answer ( ) : void
return void

channelStatus() public method

Retrieves channel status. Uses agi command "CHANNEL STATUS"
public channelStatus ( string $channel = '' ) : integer
$channel string Optional, channel name.
return integer

consoleLog() public method

Logs to asterisk console. Uses agi command "VERBOSE".
public consoleLog ( string $msg ) : void
$msg string Message to log.
return void

createNode() public method

Convenient method to create a node.
public createNode ( string $name ) : Node
$name string
return PAGI\Node\Node

createNodeController() public method

Creates a new node controller.
public createNodeController ( string $name ) : NodeController
$name string
return PAGI\Node\NodeController

databaseDel() public method

Uses agi command "DATABASE DEL".
public databaseDel ( string $family, string $key ) : void
$family string Family for key.
$key string Key name.
return void

databaseDeltree() public method

Uses agi command "DATABASE DELTREE".
public databaseDeltree ( string $family, string $key = false ) : void
$family string Family for key.
$key string Optional key name.
return void

databaseGet() public method

Uses agi command "DATABASE GET".
public databaseGet ( string $family, string $key ) : string
$family string Family for key.
$key string Key name.
return string

databasePut() public method

Uses agi command "DATABASE PUT".
public databasePut ( string $family, string $key, string $value ) : void
$family string Family for key.
$key string Key name.
$value string Value to set.
return void

dial() public method

Tries to dial the given channel.
public dial ( string $channel, array $options = [] ) : DialResult
$channel string What to dial.
$options array Dial app options
return PAGI\Client\Result\DialResult

exec() public method

Executes an application. Uses agi command "EXEC".
public exec ( string $application, array $options = [] ) : ExecResult
$application string Application name.
$options array Application arguments.
return PAGI\Client\Result\ExecResult

faxReceive() public method

Receives a fax.
public faxReceive ( string $tiffFile ) : FaxResult
$tiffFile string Absolute path to a .tiff file.
return PAGI\Client\Result\FaxResult

faxSend() public method

Sends a fax.
public faxSend ( string $tiffFile ) : FaxResult
$tiffFile string Absolute path to a .tiff file.
return PAGI\Client\Result\FaxResult

getAsteriskLogger() public method

Returns an asterisk logger facade.
public getAsteriskLogger ( ) : PAGI\Logger\Asterisk\IAsteriskLogger
return PAGI\Logger\Asterisk\IAsteriskLogger

getCDR() public method

Returns a cdr facade.
public getCDR ( ) : PAGI\CDR\ICDR
return PAGI\CDR\ICDR

getCallerId() public method

Returns a caller id facade.
public getCallerId ( ) : ICallerID
return ICallerID

getChannelVariables() public method

Returns an instance of ChannelVariables to access agi variables.
public getChannelVariables ( ) : PAGI\ChannelVariables\IChannelVariables
return PAGI\ChannelVariables\IChannelVariables

getData() public method

Reads input from user. Uses agi command "GET DATA".
public getData ( string $file, integer $maxTime, string $maxDigits ) : PlayResult
$file string File to play.
$maxTime integer Maximum time between digits before timeout.
$maxDigits string Maximum number of digits expected.
return PAGI\Client\Result\PlayResult

getFullVariable() public method

Returns a variable value. Uses agi command "GET FULL VARIABLE". False if variable is not set.
public getFullVariable ( string $name, string $channel = false ) : string
$name string Variable name.
$channel string Optional channel name.
return string

getOption() public method

Reads input from user. Uses agi command "GET OPTION".
public getOption ( string $file, string $escapeDigits, integer $maxTime ) : PlayResult
$file string File to play.
$escapeDigits string Optional sequence of digits that can be used to skip the sound.
$maxTime integer Maximum time between digits before timeout.
return PAGI\Client\Result\PlayResult

getVariable() public method

Returns a variable value. Uses agi command "GET VARIABLE". False if variable is not set.
public getVariable ( string $name ) : string
$name string Variable name.
return string

hangup() public method

Hangups the current channel. Uses agi command "HANGUP".
public hangup ( ) : void
return void

indicateBusy() public method

Indicates busy and waits for hangup. Does not play a busy tone.
public indicateBusy ( integer $timeout ) : ExecResult
$timeout integer Time in seconds to wait for hangup
return PAGI\Client\Result\ExecResult

indicateCongestion() public method

Indicates congestion and waits for hangup. Does not play a busy tone.
public indicateCongestion ( integer $timeout ) : ExecResult
$timeout integer Time in seconds to wait for hangup
return PAGI\Client\Result\ExecResult

indicateProgress() public method

Indicates progress of a call, starting early audio.
public indicateProgress ( ) : ExecResult
return PAGI\Client\Result\ExecResult

log() public method

Logs to asterisk logger. Uses application LOG.
public log ( string $msg, string $priority = 'NOTICE' ) : void
$msg string Message to log.
$priority string One of ERROR, WARNING, NOTICE, DEBUG, VERBOSE, DTMF
return void

playBusyTone() public method

Plays "Busy" tone, defined in indications.conf
public playBusyTone ( ) : ExecResult
return PAGI\Client\Result\ExecResult

playCongestionTone() public method

Plays "Congestion" tone, defined in indications.conf
public playCongestionTone ( ) : ExecResult
return PAGI\Client\Result\ExecResult

playCustomTones() public method

Plays a customized frequency tone.
public playCustomTones ( array $frequencies ) : ExecResult
$frequencies array Frequencies for the tone: 425/50,0/50 or !950/330,!1400/330,!1800/330,0 etc.
return PAGI\Client\Result\ExecResult

playDialTone() public method

Plays "Dial" tone, defined in indications.conf
public playDialTone ( ) : ExecResult
return PAGI\Client\Result\ExecResult

playTone() public method

Plays a tone defined in indications.conf.
public playTone ( string $tone ) : ExecResult
$tone string Tone to play
return PAGI\Client\Result\ExecResult

record() public method

Uses agi command "RECORD FILE".
public record ( string $file, string $format, string $escapeDigits, integer $maxRecordTime, integer $silence = false ) : PAGI\Client\Result\RecordResult
$file string Target file, without the .wav (or extension chosen).
$format string Format (wav, mp3, etc).
$escapeDigits string Optional sequence of digits that can be used to skip the sound.
$maxRecordTime integer Maximum record time (optional).
$silence integer Maximum time of silence allowed (optional)
return PAGI\Client\Result\RecordResult

sayAlpha() public method

Say a given character string, returning early if any of the given DTMF digits are received on the channel. Uses agi command "SAY PHONETIC".
public sayAlpha ( string $what, string $escapeDigits = '' ) : PlayResult
$what string What to say.
$escapeDigits string Optional sequence of digits that can be used to skip the sound.
return PAGI\Client\Result\PlayResult

sayDate() public method

Say a given date, returning early if any of the given DTMF digits are received on the channel. Uses agi command "SAY DATE".
public sayDate ( integer $time, string $escapeDigits = '' ) : PlayResult
$time integer Unix timestamp.
$escapeDigits string Optional sequence of digits that can be used to skip the sound.
return PAGI\Client\Result\PlayResult

sayDateTime() public method

Say a given date and time, returning early if any of the given DTMF digits are received on the channel. Uses agi command "SAY DATETIME".
public sayDateTime ( integer $time, string $format, string $escapeDigits = '' ) : PlayResult
$time integer Unix timestamp.
$format string Format the time should be said in.
$escapeDigits string Optional sequence of digits that can be used to skip the sound.
return PAGI\Client\Result\PlayResult

sayDigits() public method

Says digits. Uses agi command "SAY DIGITS".
public sayDigits ( string $digits, string $escapeDigits = '' ) : PlayResult
$digits string Number to say.
$escapeDigits string Optional sequence of digits that can be used to skip the sound.
return PAGI\Client\Result\PlayResult

sayNumber() public method

Says a number. Uses agi command "SAY NUMBER".
public sayNumber ( string $digits, string $escapeDigits = '' ) : PlayResult
$digits string Number to say.
$escapeDigits string Optional sequence of digits that can be used to skip the sound.
return PAGI\Client\Result\PlayResult

sayPhonetic() public method

Uses agi command "SAY PHONETIC".
public sayPhonetic ( string $what, string $escapeDigits = '' ) : PlayResult
$what string What to say.
$escapeDigits string Optional sequence of digits that can be used to skip the sound.
return PAGI\Client\Result\PlayResult

sayTime() public method

Says time. Uses agi command "SAY TIME".
public sayTime ( integer $time, string $escapeDigits = '' ) : PlayResult
$time integer Unix timestamp.
$escapeDigits string Optional sequence of digits that can be used to skip the sound.
return PAGI\Client\Result\PlayResult

sendImage() public method

Sends the given image on a channel. Uses agi command "SEND IMAGE".
public sendImage ( string $filename ) : void
$filename string Image absolute path to send.
return void

sendText() public method

Sends the given text on a channel. Uses agi command "SEND TEXT".
public sendText ( string $text ) : void
$text string Text to send.
return void

setAutoHangup() public method

Of course it can be hungup before then as well. Setting to 0 will cause the autohangup feature to be disabled on this channel. Uses agi command "SET AUTOHANGUP".
public setAutoHangup ( integer $time ) : void
$time integer Time to hangup channel.
return void

setCallerId() public method

Changes the callerid of the current channel. Uses agi command "SET CALLERID"
public setCallerId ( string $name, string $number ) : void
$name string CallerId name.
$number string CallerId number.
return void

setContext() public method

Uses agi command "SET CONTEXT".
public setContext ( string $context ) : void
$context string New context.
return void

setExtension() public method

Uses agi command "SET EXTENSION".
public setExtension ( string $extension ) : void
$extension string New extension.
return void

setLogger() public method

Sets the logger implementation.
public setLogger ( Psr\Log\LoggerInterface $logger ) : void
$logger Psr\Log\LoggerInterface The PSR3-Logger
return void

setMusic() public method

Enables/Disables the music on hold generator. Uses agi command "SET MUSIC".
public setMusic ( boolean $enable, string $class = false ) : void
$enable boolean True to enable, false to disable.
$class string If is not specified then the default music on hold class will be used.
return void

setPriority() public method

Uses agi command "SET PRIORITY".
public setPriority ( string $priority ) : void
$priority string New priority.
return void

setVariable() public method

Sets a variable. Uses agi command "SET VARIABLE".
public setVariable ( string $name, string $value ) : void
$name string Variable name.
$value string Variable value.
return void

sipHeaderAdd() public method

Adds a SIP header to the first invite message in a dial command.
public sipHeaderAdd ( string $name, string $value ) : ExecResult
$name string
$value string
return PAGI\Client\Result\ExecResult

sipHeaderRemove() public method

Removes a header previously added with sipHeaderAdd.
public sipHeaderRemove ( string $name ) : ExecResult
$name string
return PAGI\Client\Result\ExecResult

stopPlayingTones() public method

Stop playing current played tones.
public stopPlayingTones ( ) : ExecResult
return PAGI\Client\Result\ExecResult

streamFile() public method

Uses agi command "STREAM FILE"
public streamFile ( string $file, string $escapeDigits = '' ) : PlayResult
$file string File to play, without .wav extension.
$escapeDigits string Optional sequence of digits that can be used to skip the sound.
return PAGI\Client\Result\PlayResult

waitDigit() public method

Uses agi command "WAIT FOR DIGIT".
public waitDigit ( integer $timeout ) : DigitReadResult
$timeout integer Milliseconds to wait. -1 to block indefinitely.
return PAGI\Client\Result\DigitReadResult