[英]Getting files from specific folder using Drive Api (PHP)
I have a folder in my google drive and I want to list its files and subfolders using google drive Api through a search box. 我的Google驱动器中有一个文件夹,我想通过搜索框使用Google驱动器Api列出其文件和子 文件 夹 。 Does Api provide any flexibility to get folders. Api是否提供获取文件夹的任何灵活性。
I've a script to get folders but it's not working properly. 我有一个脚本来获取文件夹,但无法正常工作。 Showing some trashed folder. 显示一些已损坏的文件夹。 I want files too. 我也想要文件。
$this->client = $googl->client();
$this->drive = $googl->drive($this->client);
$folderId = '0B4JDg65OBlTM3RseUk';
$parameters = [
'q' => "'$folderId' in parents",
'fields' => 'files(id, name, modifiedTime, iconLink,
webViewLink, webContentLink)'];
$result = $this->drive->files->listFiles($parameters);
To list files, you may use the files.list
method of the API. 要列出文件,您可以使用API的files.list
方法。 This method accepts the q
parameter, which is a search query combining one or more search terms. 此方法接受q
参数,该参数是将一个或多个搜索词组合在一起的搜索查询。
Response: 响应:
{
"kind": "drive#fileList",
"nextPageToken": string,
"incompleteSearch": boolean,
"files": [
files Resource
]
}
Example for files.list
: 例如files.list
:
Search for the ID
1234567
in theparents
collection. 在parents
集合中搜索ID1234567
。 This finds all files and folders located directly in the folder whose ID is1234567
. 这将查找直接位于ID为1234567
的文件夹中的所有文件和文件夹。
'1234567' in parents
To see the valid search parameters, you may visit this link . 要查看有效的搜索参数,您可以访问此链接 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.