如何使用Cpanel UAPI输出stdclass?

时间:2018-07-21 14:42:19

标签: php cpanel

我正在尝试获取网站的带宽数据。我正在使用此类来获取数据:https://github.com/N1ghteyes/cpanel-UAPI-php-class/blob/master/cpaneluapi.class.php 它可以工作,但我不知道如何使用它提供的数据。

我使用以下php代码来获取数据:

    $cPanel = new cpanelAPI('*******', '******', '*****');
$resource = $cPanel->uapi->ResourceUsage->get_usages();

当我使用“ var_dump($ resource)”时得到的响应是:

  

object(stdClass)#3(6){[“元数据”] => object(stdClass)#2(1){[“ transformed”] => int(1)} [“ messages”] => NULL [“警告”] => NULL [“错误”] => NULL [“状态”] => int(1)[“数据”] => array(19){[0] => object(stdClass)#4 (6){[“ formatter”] =>字符串(12)“ format_bytes” [“ description”] =>字符串(16)“ DiskKullanımı” [“ url”] =>字符串(20)“ diskusage / index.html “ [”“ maximum”] => NULL [“ id”] => string(10)“ disk_usage” [“ usage”] => int(4854559791)} [1] => object(stdClass)#5(6){ [“ description”] =>字符串(24)“MySQL®DiskKullanımı” [“ formatter”] =>字符串(12)“ format_bytes” [“ url”] => NULL [“ id”] =>字符串(20) “” cachedmysqldiskusage“ [”用法“] => int(71367805)[”最大值“] => NULL} [2] => object(stdClass)#6(6){[”“ description”] => string(16)“ BantGenişliği“ [” formatter“] =>字符串(12)” format_bytes“ [” url“] =>字符串(20)” stats / bandwidth.html“ [” id“] =>字符串(9)” bandwidth“ [ “ usage”] => string(11)“ 63120390532” [“ maximum”] => NULL} [3] => object(stdClass)#7(6){[“” formatter“] => NULL [” description“] =>字符串(22)“ Eklenti EtkiAlanları” [“” URL“] =>字符串(16)” addon / index.html“ [” maximum“] => NULL [” id“] =>字符串(13)” addon_domains“ [ “ usage”] => int(0)} [4] => object(stdClass)#8(6){[“ url”] => string(20)“ subdomain / index.html” [“ formatter”] = > NULL [“ description”] =>字符串(18)“ Alt EtkiAlanları” [“ maximum”] => NULL [“ usage”] => int(5)[“ id”] => string(10)“子域“} [5] => object(stdClass)#9(6){[” description“] => string(8)” Rumuzlar“ [” formatter“] => NULL [” url“] => string(15) “ park / index.html” [“ maximum”] => NULL [“ id”] => string(7)“ aliases” [“ usage”] => int(0)} [6] => object(stdClass) #10(6){[“ description”] =>字符串(18)“ E-postaHesapları” [“ formatter”] => NULL [“ url”] =>字符串(20)“ mail / pops / index.html “ [” id“] =>字符串(14)” email_accounts“ [”用法“] =>字符串(1)” 5“ [”最大“] => NULL} [7] => object(stdClass)#11( 6){[“” maximum“] => NULL [” usage“] => int(1)[” id“] => string(13)” mailing_lists“ [” url“] => string(15)” mail / list.html“ [”描述“] =>字符串(15)” Posta Listeleri“ [”表单atter“] => NULL} [8] => object(stdClass)#12(6){[”“最大”] => NULL [“用法”] => int(1)[“ id”] =>字符串( 14)“ autoresponders” [“ url”] =>字符串(17)“ mail / autores.html” [“ formatter”] => NULL [“ description”] =>字符串(26)“ OtomatikYanıtlayıcılar”} [9] => object(stdClass)#13(6){[“” url“] =>字符串(14)” mail / fwds.html“ [”描述“] =>字符串(11)”İleticiler“ [” formatter“] = > NULL [“ maximum”] => NULL [“ usage”] => int(1)[“ id”] => string(10)“ forwarders”} [10] => object(stdClass)#14(6) {[“” url“] =>字符串(31)” mail / filters / managefilters.html“ [”格式化程序“] => NULL [”描述“] =>字符串(18)” E-posta Filtreleri“ [”用法“ ] => int(0)[“ id”] =>字符串(13)“ email_filters” [“ maximum”] => NULL} [11] => object(stdClass)#15(6){[“ url”] =>字符串(17)“ ftp / accounts.html” [“ formatter”] => NULL [“ description”] =>字符串(14)“ FTPHesapları” [“ maximum”] => NULL [“用法”] = > string(1)“ 0” [“ id”] => string(12)“ ftp_accounts”} [12] => object(stdClass)#16(6){[“ usage”] => int(9)[ “ id”] =>字符串(15)“ mysql_databases” [“ maximum”] => NULL [“ url”] => string(14)“ sql / index.html” [“ description”] => string(22)“MySQL®Veritabanları” [“ formatter”] => NULL } [13] => object(stdClass)#17(6){[“” url“] => NULL [” formatter“] => NULL [” description“] => string(15)” CPUKullanımı“ [” maximum “] => int(100)[”用法“] => int(5)[” id“] =>字符串(6)” lvecpu“} [14] => object(stdClass)#18(6){[ “ url”] => NULL [“ description”] => string(18)“GirişSüreçleri” [“ formatter”] => NULL [“ usage”] => int(1)[“ id”] => string( 5)“ lveep” [“ maximum”] => int(200)} [15] => object(stdClass)#19(6){[“” url“] => NULL [” description“] =>字符串(21 )“物理内存使用情况” [“格式化程序”] =>字符串(12)“ format_bytes” [“用法”] => int(39809024)[“ id”] =>字符串(9)“ lvememphy” [“最大”] => int(1572864000)} [16] => object(stdClass)#20(6){[“”最大“] => int(1024)[”用法“] => int(0)[” id“] = >字符串(7)“ lveiops” [“ url”] => NULL [“ formatter”] => NULL [“ description”] =>字符串(4)“ IOPS”} [17] => object(stdClass)#21 (6){[“ formatter”] =>字符串(23)“ format_bytes_per _second“ [” description“] => string(9)” I / O用法“ [” url“] => NULL [” maximum“] => int(3145728)[” id“] => string(5)” lveio“ [”用法“] => int(3072)} [18] => object(stdClass)#22(6){[”“ maximum”] => int(1000)[“ id”] =>字符串(8 )“ lvenproc” [“用法”] => int(6)[“ description”] =>字符串(19)“进程数” [“ formatter”] => NULL [“ url”] => NULL}}}

我需要使数据可用。


自己找到了解决方案:)

echo $resource->data[2]->usage;

0 个答案:

没有答案