[英]Get List of All Folders In Google Drive - Google Drive API
Is there any way to get a list of all folders in "My Drive" using the Google Drive API.有没有办法使用 Google Drive API 获取“我的云端硬盘”中所有文件夹的列表。 Here is the function I am trying to write.这是我正在尝试编写的 function。
function getAllFolders(){
// Get all folders
}
(I looked at some other stack overflow posts but they weren't very helpful for me). (我查看了其他一些堆栈溢出帖子,但它们对我没有多大帮助)。
With the query string q
, you can search for files and folders following the syntax in the documentation使用查询字符串q
,您可以按照文档中的语法搜索文件和文件夹
Using mimeType = 'application/vnd.google-apps.folder'
in the query string, to get just the folders.在查询字符串中使用mimeType = 'application/vnd.google-apps.folder'
来获取文件夹。
there is a simple exemple:有一个简单的例子:
<?php
$service = new Google_Service_Drive($client);
$folderID = "root";
$optParams = array(
'pageSize' => 100,
'fields' => 'nextPageToken, files(id, name, mimeType, modifiedTime, size, parents)',
'q' => "mimeType = 'application/vnd.google-apps.folder' and '".$folderID."' in parents"
);
$results = $service->files->listFiles($optParams);
foreach ($results as $file) {
// do somethings
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.