category OSS
package OSS_Asterisk
copyright Copyright (c) 2007 - 2012, Open Source Solutions Limited, Dublin, Ireland
license New BSD License

 Methods

Parse channel response.

parseChannelResponse($response) : array
Static

It takes response array it checks if response have data. If it has it tries to parse form this type of array: Array ( [data] => Privilege: Command -- General -- Name: SIP/pcustomer-0000010a Type: SIP UniqueID: 1350570966.266 LinkedID: 1350570966.266 ... Indirect Bridge: SIP/ptelco-0000010b -- PBX -- Context: fwd-call Extension: 1201 ... Variables: BRIDGEPVTCALLID=4093270c7dd45f224ffff58f129f3275@192.168.40.42:5060 BRIDGEPEER=SIP/ptelco-0000010b ... SIPURI=sip:1101@192.168.40.43:5060

 CDR Variables:
       level 1: dnid=1201
       level 1: calldate=2012-10-18 15:36:07
       ...
       level 1: sequence=337

[Response] => Follows ) To this type of array: Array ( [] => Array ( [Privilege] => Command ) [general] => Array ( [Name] => SIP/pcustomer-0000010a [Type] => SIP [UniqueID] => 1350570967.266 [LinkedID] => 1350570966.266 ... [Indirect Bridge] => SIP/ptelco-0000010b ) [pbx] => Array ( [Context] => fwd-call [Extension] => 1201 ... [Variables] => Array ( [BRIDGEPVTCALLID] => 4093270c7dd45f224ffff58f129f3275@192.168.40.42:5060 [BRIDGEPEER] => SIP/ptelco-0000010b ... [SIPURI] => sip:1101@192.168.40.43:5060 ) ) [cdr] => Array ( [dnid] => 1201 [calldate] => 2012-10-18 15:36:07 ... [sequence] => 337 ) )

Usage: $presp = $ami->command( "core show channel CHANNEL_NAME" ); $result = OSS_Asterisk_AMI_Parser::parseChannelResponse( $presp );

var

Response of AMI command

Parameters

$response

Returns

array

Parse channels response when channels call had attribute concise.

parseChannelsConciseResponse($response) : array
Static

It takes response array it checks if response have data. If it has it tries to parse form this type of array: Array ( [data] => Privilege: Command SIP/ptelco-00000113!ttelco!!1!Up!AppDial!(Outgoing Line)!1201!cust1!cust1!3!15!SIP/pcustomer-00000112!1350573839.275 SIP/pcustomer-00000112!fwd-call!1201!6!Up!Dial!SIP/ptelco/1201!1101!cust1!cust1!3!15!SIP/ptelco-00000113!1350573837.274

   [Response] => Follows

) To this type of array: Array ( [0] => Array ( [0] => SIP/ptelco-00000113 [1] => ttelco [2] => [3] => 1 [4] => Up [5] => AppDial [6] => (Outgoing Line) [7] => 1201 [8] => cust1 [9] => cust1 [10] => 3 [11] => 15 [12] => SIP/pcustomer-00000112 [13] => 1350573839.275 ) [1] => Array ( [0] => SIP/pcustomer-00000112 ... [13] => 1350573837.274 ) )

Usage: $resp = $ami->command( "core show channels concise" ); $result = OSS_Asterisk_AMI_Parser::parseChannelsConciseResponse( $resp );

var

Response of AMI command

Parameters

$response

Returns

array

Parse the response to a `sip show peer $peer` command

parseSipShowPeerResponse(array $response) : array
Static

This function takes the response array of the form:

Array
(
    [data] => "Privilege: Command

       * Name       : pcustomer
       Secret       : <Set>
       MD5Secret    : <Not set>
       ...
       ToHost       : customer
       Addr->IP     : 192.168.40.43:5060
       ...
       Encryption   : No"

   [Response] => Follows
)

and converts it to an associate array:

Array
(
    [Privilege] => Command
    [* Name] => pcustomer
    [Secret] => <Set>
    ...
    [ToHost] => customer
    [Addr->IP] => 192.168.40.43:5060
    [Addr] = Array
             (
                 [IP] => 192.168.40.43
                 [Port] => 5060
             )
    ...
    [Encryption] => No
)

Example usage:

$resp = $ami->command( "sip show peer PEER_NAME" );
$result = OSS_Asterisk_AMI_Parser::parsePeerResponse( $resp );

Parameters

$response

array

Response of AMI command

Returns

array