繁体   English   中英

如何使用 PHP 使用 Google Drive API 显示服务帐户中使用的当前存储空间?

[英]How to display current storage used in service account with Google Drive API using PHP?

请问如何显示我的Google Drive API的服务帐户中使用的当前存储空间?

我试图在字段中调用它,但它不起作用。

$parameters['fields'] = 'files(storage), nextPageToken';

通过键入标题,我似乎无法在此处找到帖子,但我找不到任何帖子。

使用 Drive API 的“About: get”怎么样? 当这反映到使用 googleapis for PHP 的 PHP 脚本时,它变为如下。

示例脚本:

$service = new Google_Service_Drive($client); // Please use your "$client".
$res = $service->about->get(['fields' => 'storageQuota']);
$storageQuota = $res -> getStorageQuota();
print_r($storageQuota);

// When you want to retrieve the value of "usage` of "storageQuota", you can do it as follows.
$usage = $storageQuota -> getUsage();
echo $usage;

运行上述脚本时,将获得以下值。

{
  "limit": "###",
  "usage": "###",
  "usageInDrive": "###",
  "usageInDriveTrash": "###"
}

参考:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM