The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Gathering user data

Discussion in 'cPanel Developers' started by NLCJ, Mar 22, 2012.

  1. NLCJ

    NLCJ Member

    Joined:
    Sep 25, 2009
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hello everyone,
    I'm trying to use the cPanel API in order to retrieve the diskspace and bandwidth used. Therefore I downloaded the API class (http://forums.cpanel.net/f42/xml-api-php-class-version-1-0-a-136449.html) from GitHUB. However, I have some trouble with the array... I can't figure out how to get only one value. The code I use is:
    PHP:
    $xmlapi = new xmlapi($ip);
    $xmlapi->hash_auth("root",$root_hash);
    $xmlapi->return_xml(0);
    $xmlapi->set_debug(1);

    echo 
    $xmlapi->accountsummary('account');
    This works, but how do I get the diskspace used? I tried a few things, including:
    PHP:
    $xmlapi = new xmlapi($ip);
    $xmlapi->hash_auth("root",$root_hash);
    $xmlapi->return_xml(0);
    $xmlapi->set_debug(1);

    echo 
    $xmlapi->accountsummary('account')->accountsummary->acct->diskused;
    I'm kind of lost, and only used XML a few times before. If someone can give me a push in the right direction, it would be greatly appreciated. :)

    Regards,
    Chris

    P.s. Is it also possible to force cPanel to recalculate the disk space / bandwidth used using the API?
     
  2. NLCJ

    NLCJ Member

    Joined:
    Sep 25, 2009
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Okay, I solved it using a xml2array class; this one: xml2array() - XML Parser for PHP < PHP < Bin-Co.

    However, my other question has not been answered (yet). Is it possible to force cPanel to refresh the disk usage data? At this moment it is incorrect for some accounts, if possible, I would like to do this using the API.
     
Loading...

Share This Page