[英]How to display current storage used in service account with Google Drive API using PHP?
Can I ask if how will I display the current storage used in my service account of Google Drive API?请问如何显示我的Google Drive API的服务帐户中使用的当前存储空间?
I tried to call it in fields but its not working.我试图在字段中调用它,但它不起作用。
$parameters['fields'] = 'files(storage), nextPageToken';
I can't seem to find a post here by typing the title but I can't find any.通过键入标题,我似乎无法在此处找到帖子,但我找不到任何帖子。
How about using "About: get" of Drive API?使用 Drive API 的“About: get”怎么样? When this is reflected to the PHP script using googleapis for PHP, it becomes as follows.当这反映到使用 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;
When above script is run, the following value is obtained.运行上述脚本时,将获得以下值。
{
"limit": "###",
"usage": "###",
"usageInDrive": "###",
"usageInDriveTrash": "###"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.