【问题标题】:Google Drive API Search for foldersGoogle Drive API 搜索文件夹
【发布时间】:2020-04-18 23:38:58
【问题描述】:

我正在尝试获取文件夹列表,以便可以搜索所有子文件夹中的文件。我正在使用这篇文章(备选方案 3)作为参考 https://stackoverflow.com/a/41741521/1485815

我的查询是这样的(我在查询中试过mimetype和mimeType)

    $optParams = array(
    'pageSize' => 1000
        ,'fields' => 'nextPageToken, files(contentHints/thumbnail,fileExtension,iconLink,id,name,size,thumbnailLink,webContentLink,webViewLink,mimeType,parents, kind, trashed, owners, modifiedTime)'
        ,'q' => "mimeType=application/vnd.google-apps.folder"
       );                

    $service = new \Google_Service_Drive($this->GoogleClient);
    $results = $service->files->listFiles($optParams);

我的身份验证很好,但是这个查询给出了以下详细信息的错误

 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "invalid",
    "message": "Invalid Value",
    "locationType": "parameter",
    "location": "q"
   }
  ],
  "code": 400,
  "message": "Invalid Value"
 }

}

【问题讨论】:

    标签: google-drive-api


    【解决方案1】:
    • 您想通过 PHP 使用 googleapis 从 Google Drive 中检索文件夹列表。
    • 您已经能够使用 Drive API。
    • 您想知道Invalid Value问题的原因。

    修改后的脚本:

    从:
    ,'q' => "mimeType=application/vnd.google-apps.folder"
    
    至:
    ,'q' => "mimeType='application/vnd.google-apps.folder'"
    

    ,'q' => 'mimeType="application/vnd.google-apps.folder"'
    
    • 请用'"将mimeType的值括起来。

    参考:

    【讨论】:

    • @StripyTiger 感谢您的回复。很高兴您的问题得到解决。
    • 嗨 - 我想知道你是否介意检查这个问题 - 我似乎无法使用我的查询来查询多个文件夹。 stackoverflow.com/questions/61313289/…谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-11-07
    • 1970-01-01
    • 2013-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多