0
$cpanel = new cPanel('username','pass','domain');

$bandwidth_report = $cpanel->uapi(
        'Bandwidth', 'query',
        array(
            'grouping'        => "domain|year",
            'interval'        => 'daily',
            'protocols'       => 'http|imap|smtp',
            'timezone'        => 'America|Chicago',
            )
    );
var_dump($bandwidth_report);

I have the following output:

object(stdClass)#2 (6) { 
    ["messages"]=> NULL 
    ["status"]=> int(1) 
    ["metadata"]=> object(stdClass)#3 (0) { } 
    ["data"]=> object(stdClass)#5 (2) { 
                ["UNKNOWN"]=> object(stdClass)#4 (1) { 
                        ["1577836800"]=> int(27918) 
                } 
                ["chillberryconsulting.com"]=> object(stdClass)#6 (1) { 
                        ["1577836800"]=> int(36155409) 
                } 
    } 
    ["errors"]=> NULL ["warnings"]=> NULL 
}

The question is, I want to get the data from the "data" field in the result and echo it one by one in PHP.

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
  • `$yourObject->someProperty;` Try searching the [manual](https://www.php.net/manual/en/language.types.object.php) for more info. – Gavin Apr 14 '20 at 16:02
  • Please specify Exactly what data you want – RiggsFolly Apr 14 '20 at 16:02
  • `$bandwidth_report->data->UNKNOWN->1577836800` that is not a very well organised data structure though – RiggsFolly Apr 14 '20 at 16:04
  • ["data"]=> object(stdClass)#5 (2) { ["UNKNOWN"]=> object(stdClass)#4 (1) { ["1577836800"]=> int(27918) } ["chillberryconsulting.com"]=> object(stdClass)#6 (1) { ["1577836800"]=> int(36155409) } } This data – NoobScorpio Apr 14 '20 at 16:05
  • Cpanel api is returning that data, what can I do about that? – NoobScorpio Apr 14 '20 at 16:07

0 Answers0