Skip to main content

[Resolved] Use api 2 call to get user information and convert it to php variable

Comments

2 comments

  • vanessa
    Just set the result to a variable: hash_auth($server_username, $root_hash); $xmlapi->set_debug(0); $args = array('display' => 'bandwidthusage'); $result = $xmlapi->api2_query($cpanel_username, 'StatsBar', 'stat', $args); print_r($result);
    This will return: [SimpleXMLElement Object ( [apiversion] => 2 [data] => SimpleXMLElement Object ( [name] => bandwidthusage [_count] => 8.97 [_max] => unlimited [_maxed] => 0 [count] => 8.97 [feature] => bandwidth [id] => bandwidthusage [item] => Monthly Bandwidth Transfer [langkey] => INDXBandwidth [max] => unlimited [module] => Stats [normalized] => 1 [percent] => 0 [percent10] => 0 [percent20] => 0 [percent5] => 0 [units] => MB [zeroisunlimited] => 1 ) [event] => SimpleXMLElement Object ( [result] => 1 ) [func] => stat [module] => StatsBar )
    Then all you have to do is pull out the variables you want. For example, to get the value of _max in the above result: $max = $result->data->_max;
    Will return: unlimited
    Hope this helps.
    0
  • cPanelMichael
    Hello :) The previous post seems to accurately answer your question so I am marking this thread as resolved. Feel free to update this thread if you have any additional questions. Thank you.
    0

Please sign in to leave a comment.