Hello.
I am trying to extract disk and bandwidth usage from cPanel accounts under a reseller. To this end, I am using the cPanel API2 StatsBar->stats->display. The problem I am having is authenticating. When I use the reseller password to log in to any account below the reseller, everything works fine. However, this seems like a bad solution as opposed to using access hashes. But when using the access hash of the reseller account instead (located in /home/reseller/.accesshash), I get access denied errors.
Could anyone tell me what I am doing wrong? Am I not supposed to be using access hashes here? Is the use of reseller passwords the advocated and approved solution?
Thanks a lot. My code is below.
Devel.
I am trying to extract disk and bandwidth usage from cPanel accounts under a reseller. To this end, I am using the cPanel API2 StatsBar->stats->display. The problem I am having is authenticating. When I use the reseller password to log in to any account below the reseller, everything works fine. However, this seems like a bad solution as opposed to using access hashes. But when using the access hash of the reseller account instead (located in /home/reseller/.accesshash), I get access denied errors.
Could anyone tell me what I am doing wrong? Am I not supposed to be using access hashes here? Is the use of reseller passwords the advocated and approved solution?
Thanks a lot. My code is below.
Devel.
Code:
...
$cpCfg = array('cpanel' => array('service' => array('cpanel' => array(
'host' => 'ip goes here',
'user' => 'any cPanel account goes here',
//'password' => 'reseller password goes here'
'accesshash' => $access-hash-without-newlines-goes-here
))));
$cp = Cpanel_PublicAPI::getInstance($cpCfg);
$queryMF = array(
'module' => 'StatsBar',
'function' => 'stat',
);
$queryArgs = array(
'display' => 'diskusage|bandwidthusage'
);
$response = $cp->cpanel_api2_request('cpanel', $queryMF, $queryArgs);
echo '<pre>'.print_r($response, true).'</pre>';
...