cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
433
Views
0
Helpful
0
Comments
cdnadmin
Community Member
This document was generated from CDN thread

Created by: JAMES DEPHILLIP II on 27-10-2010 01:05:53 PM
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);
 
?>

Subject: RE: Filtering selectCmDevice in PHP
Replied by: JAMES DEPHILLIP II on 28-10-2010 03:10:33 PM
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);
 
?>

Subject: RE: Filtering selectCmDevice in PHP
Replied by: JAMES DEPHILLIP II on 27-10-2010 06:17:29 PM
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
                                        )
                                )
                        )
                )
        )
     =>
)
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links