gpt4 book ai didi

php - 谷歌云端硬盘 API v3 : Invalid field selection

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:04:47 26 4
gpt4 key购买 nike

我正在使用 Google Drive API v3 访问有关驱动器的空间配额。

而且,无论我做什么,我都会遇到这个错误:

Fatal error: Uncaught exception 'Google_Service_Exception' with message 'Error calling **GET https://www.googleapis.com/drive/v3/about?fields=name**: (400) Invalid field selection name' in /var/webs/includes/google-api-php-client/src/Google/Http/REST.php:110 

Stack trace:
#0 /var/webs/includes/google-api-php-client/src/Google/Http/REST.php(62): Google_Http_REST::decodeHttpResponse(Object(Google_Http_Request), Object(Google_Client))
#1 [internal function]: Google_Http_REST::doExecute(Object(Google_Client), Object(Google_Http_Request))
#2 /var/webs/includes/google-api-php-client/src/Google/Task/Runner.php(174): call_user_func_array(Array, Array)
#3 /var/webs/includes/google-api-php-client/src/Google/Http/REST.php(46): Google_Task_Runner->run()
#4 /var/webs/includes/google-api-php-client/src/Google/Client.php(593): Google_Http_REST::execute(Object(Google_Client), Object(Google_Http_Request))
#5 /var/webs/includes/goog in /var/webs/includes/google-api-php-client/src/Google/Http/REST.php on line 110


$googleClient = $this->getClient();
$googleClient->setAccessToken($accessToken);
$googleDrive = new Google_Service_Drive($googleClient);
//fields can be found here: https://developers.google.com/drive/v3/web/migration#fields
$optParams = array(
'fields' => 'name'
);
print_r($googleDrive->about->get($optParams));

请检查我是否已经为调用创建了一个完美的 URL:获取 https://www.googleapis.com/drive/v3/about?fields=name但是,仍然存在这个错误。是否缺少任何参数?

拜托,谁能告诉我API本身是否有问题?

最佳答案

在 v3 中,字段定义已更改,应该是

fields=storageQuota,user/displayName

代替

fields=name

无论如何,我没有使用 PHP 的经验。

引用:
https://developers.google.com/drive/v2/reference/about https://developers.google.com/drive/v3/reference/about


您可以自行检查所有可用字段:现在这些是我找到的字段:appInstalled、exportFormats、folderColorPalette、importFormats、kind、maxImportSizes、maxUploadSize、storageQuota & user

如果您需要检查哪些字段是允许的,请转到 https://developers.google.com/drive/v3/reference/about/get & 做“试试吧!”。

关于php - 谷歌云端硬盘 API v3 : Invalid field selection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38853938/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com