Howto:Retrieve configuration of all PBX Objects using SOAP API: Difference between revisions
mNo edit summary |
mNo edit summary |
||
Line 17: | Line 17: | ||
Therefore use SOAP API function [[Reference10:SOAP_API#UserInfo.5B.5D_FindUser.28string_v501.2C_string_v700.2C_string_v800.2C_string_vx1000.2C_string_cn.2C_string_h323.2C_string_e164.2C_integer_count.2C_integer_next.2C_boolean_nohide.29|FindUser]] to get parts of the PBX Objects list. The best practice is to get PBX Objects names in pages with 50 Objects. Than retrieve the corresponding Object details one by one as XML data set. | Therefore use SOAP API function [[Reference10:SOAP_API#UserInfo.5B.5D_FindUser.28string_v501.2C_string_v700.2C_string_v800.2C_string_vx1000.2C_string_cn.2C_string_h323.2C_string_e164.2C_integer_count.2C_integer_next.2C_boolean_nohide.29|FindUser]] to get parts of the PBX Objects list. The best practice is to get PBX Objects names in pages with 50 Objects. Than retrieve the corresponding Object details one by one as XML data set. | ||
An example code | An example code based on the [[Howto:SOAP API PHP5 Sample Code]]: | ||
<code php> | <code php> | ||
Line 23: | Line 23: | ||
$last_user_cn = ""; // start with an empty string to get first objects | $last_user_cn = ""; // start with an empty string to get first objects | ||
while (true) { | while (true) { | ||
$users = $inno->FindUser(true, true, true, true, $last_user_cn, null, null, 50, $next, false); | $users = $inno->FindUser(true, true, true, true, $last_user_cn, null, null, 50, $next, false); | ||
if (count($users) == 0) break; // stop, in case no objects delivered | if (count($users) == 0) break; // stop, in case no objects delivered | ||
$next = true; | $next = true; | ||
$last_user_cn = end($users)->cn; | $last_user_cn = end($users)->cn; | ||
foreach ($users as $user) { //iterate through the object list | |||
// prepare XML request | |||
// an empty show tag | |||
$show = new SimpleXMLElement("<show/>"); | |||
// add the user tag | |||
$user = $show->addChild("user"); | |||
// add the "cn" attribute | |||
$user->addAttribute("cn", $user->cn); | |||
// set the config attribute. "true makes sure we get the config as configured only, otherwise, all templates are applied | |||
// weird enough, the opposite would be not config attribute present, a value of "false" will not do! | |||
if ($config) $user->addAttribute("config", "true"); | |||
//print "cmd: " . htmlspecialchars($show->asXML()) . "\n"; | |||
echo $user->cn.":\r\n"; | echo $user->cn.":\r\n"; | ||
echo ($inno->Admin( | echo ($inno->Admin($show->asXML())); //get XML data of the each particular object | ||
echo "\r\n"; | echo "\r\n"; | ||
} | } | ||
}</code> | } | ||
</code> | |||
==Related Articles== | ==Related Articles== | ||
[[Howto:SOAP API PHP5 Sample Code]] | |||
[[Reference10:SOAP API]] | [[Reference10:SOAP API]] |
Revision as of 09:21, 22 July 2015
Here is a description of the method how to get the complete PBX Object list and the associated Object configuration as an XML dataset.
Applies To
This information applies to
- all PBX platforms
More Information
Problem Details
The SOAP API function Admin can be used to list all PBX Objects and their contents by providing a wild card search parameter * as search string for cn.
However, on the large PBXes with big number of PBX Objects, this may fail, because the system can not deliver all the data in one single batch.
Solution
The solution is to retrieve the data in multiple smaller pages.
Therefore use SOAP API function FindUser to get parts of the PBX Objects list. The best practice is to get PBX Objects names in pages with 50 Objects. Than retrieve the corresponding Object details one by one as XML data set.
An example code based on the Howto:SOAP API PHP5 Sample Code:
$next = false;
$last_user_cn = ""; // start with an empty string to get first objects
while (true) {
$users = $inno->FindUser(true, true, true, true, $last_user_cn, null, null, 50, $next, false);
if (count($users) == 0) break; // stop, in case no objects delivered
$next = true;
$last_user_cn = end($users)->cn;
foreach ($users as $user) { //iterate through the object list
// prepare XML request
// an empty show tag
$show = new SimpleXMLElement("<show/>");
// add the user tag
$user = $show->addChild("user");
// add the "cn" attribute
$user->addAttribute("cn", $user->cn);
// set the config attribute. "true makes sure we get the config as configured only, otherwise, all templates are applied
// weird enough, the opposite would be not config attribute present, a value of "false" will not do!
if ($config) $user->addAttribute("config", "true");
//print "cmd: " . htmlspecialchars($show->asXML()) . "\n";
echo $user->cn.":\r\n";
echo ($inno->Admin($show->asXML())); //get XML data of the each particular object
echo "\r\n";
}
}