简体   繁体   English

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

[英]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 脚本时,它变为如下。

Sample script:示例脚本:

$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": "###"
}

Reference:参考:

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

相关问题 如何通过服务帐户使用 Google Drive PHP Api - How to use Google Drive PHP Api with service account 如何使用PHP的服务帐户将文件上传到Google云端硬盘? - How to upload a file to Google Drive using Service Account in PHP? Google Drive API V3 在不使用服务帐户的情况下使用 php 将文件复制到另一个驱动器 - Google drive API V3 make a copy of file to another drive without using service account using php 如何使用服务帐户和 php 上传到谷歌驱动器 - How to upload to google drive with service account and php 使用API​​对Google云端硬盘文件和服务帐户的所有权 - Ownership of Google Drive files and Service Account using API 使用服务帐户在php上使用Google Calendar API - Google Calendar API on php using service account 带有服务帐户的Google Drive API无法正常工作 - Google drive API with service account is not working Google Drive API:使用服务帐户复制文件 - Google Drive API: copy file with service account 如何在不使用Google Apps的情况下授权Google Drive服务帐户访问Google帐户? - How do I authorize a google drive service account access to a google account without using google apps? 如何使用PHP使用Google Drive API正确定义Google_Service_Drive变量来创建文件夹? - How can I define a Google_Service_Drive variable correctly with Google Drive API using PHP to create a folder?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM