通过 file/folder 的名称从 google 驱动器 api 中搜索文件或文件夹?

Search for a file or folder from google drive api via the name of the file/folder?

我正在尝试制作一个可以搜索 file/folder 的函数。如果 file/folder 存在,那么它将 return id else 将从 PHP 中的驱动器中 return 为空,但每次我这样做时,它都表明存在一些错误问.

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

查询是:-

//testing-folder-of-api is the name of the folder
mimeType=application/vnd.google-apps.folder and name='testing-folder-of-api'

我也试过像这样改变它:

  1. mimeType!=application/vnd.google-apps.folder 如果不是文件
  2. name contains 'test.txt'title='test.txt' 按名称搜索。

我找到的解决方案是循环遍历所有文件并使用循环逐个检查名称,这需要花费很多时间。

谁能告诉我怎么做。请!!

问题:

您应该在 'application/vnd.google-apps.folder' 周围添加单引号,如 File-specific query terms:

所述

mimeType: MIME type of the file. Surround with single quotes '.

解决方案:

mimeType='application/vnd.google-apps.folder' and name='testing-folder-of-api'