« Back to Serviceability XML Questions

Filtering selectCmDevice in PHP

Combination View Flat View Tree View
Threads [ Previous | Next ]
How can I filter this PHP query to only retrieve the IP addresses of the devices? Any help would be greatly appreciated. I want to be able to execute a command on the returned items. Thanks in advance!
 
<?php
 
define('CUCM_SERVER_IP',  'myserver');
define('CUCM_SERVER_PORT','8443');
define('CUCM_AXL_USER',   'myuser');
define('CUCM_AXL_PASS',   'mypass');
define('CUCM_AXL_API',    '/Library/WebServer/Documents/Risport.wsdl');
 
$client = new SoapClient(CUCM_AXL_API,
array('trace'=>true,
'exceptions'=>true,
'location'=>"https://".CUCM_SERVER_IP.":".CUCM_SERVER_PORT."/realtimeservice/services/RisPort",
'login'=>CUCM_AXL_USER,
'password'=>CUCM_AXL_PASS));
 
$devices = $client->SelectCmDevice(
    "",
    array(
        "SelectBy" => "Name",
        "Status" => "Registered"
    )
);
 
print_r($devices);
 
?>

This is the return I get from axl. I just do not understand how I can extract just the IpAddress Values.
 
Array
(
[SelectCmDeviceResult] => stdClass Object
(
[TotalDevicesFound] => 3
=> Array
(
[0] => stdClass Object
(
=> Ok
=> CCM-IP
=>
=> Array
(
[0] => stdClass Object
(
=> SEP000F34D063E0
=> 10.10.40.186
)
[1] => stdClass Object
(
=> SEP0021A08F33E7
=> 10.10.40.30
)
[2] => stdClass Object
(
=> SEP0024C442CF2E
=> 10.10.40.48
)
)
)
)
)
=>
)

So after quite some time I have figured it out.  For those of you who wish to export an array of IP address of registered phones from CM using PHP here it is. If anyone have a way to clean this up feel free.
 
 
<?php
 
define('CUCM_SERVER_IP',  'x.x.x.x');
define('CUCM_SERVER_PORT','8443');
define('CUCM_AXL_USER',   'xxxxxxx');
define('CUCM_AXL_PASS',   'xxxxxxx');
define('CUCM_AXL_API',    '/Library/WebServer/Documents/RisportIP.wsdl');
 
$client = new SoapClient(CUCM_AXL_API,
array('trace'=>true,
'exceptions'=>true,
'location'=>"https://".CUCM_SERVER_IP.":".CUCM_SERVER_PORT."/realtimeservice/services/RisPort",
'login'=>CUCM_AXL_USER,
'password'=>CUCM_AXL_PASS));
 
$devices = $client->SelectCmDevice(
    "",
    array(
        "SelectBy" => "Name",
        "Status" => "Registered",
"Class" => "Phone"
    )
);
 
$RegPhoneIP = array(  );
 
foreach( $devices as $first){
       if( is_array($first->CmNodes) ){
$CmNodes = $first->CmNodes;
foreach( $CmNodes as $second){
if( is_array($second->CmDevices) ){
$CmDevices = $second->CmDevices;
foreach( $CmDevices as $third){
$RegPhoneIP = array_merge_recursive($RegPhoneIP, array($third->IpAddress));
}
}
}
}
}
 
print_r ($RegPhoneIP);
 
?>