簡體   English   中英

獲取 Google Drive 中所有文件夾的列表 - Google Drive API

[英]Get List of All Folders In Google Drive - Google Drive API

有沒有辦法使用 Google Drive API 獲取“我的雲端硬盤”中所有文件夾的列表。 這是我正在嘗試編寫的 function。

function getAllFolders(){
    // Get all folders
}

(我查看了其他一些堆棧溢出帖子,但它們對我沒有多大幫助)。

使用查詢字符串q ,您可以按照文檔中的語法搜索文件和文件夾

在查詢字符串中使用mimeType = 'application/vnd.google-apps.folder'來獲取文件夾。

有一個簡單的例子:

<?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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM