Php GoogleDrive API V3:无法列出子文件夹的内容
我想将文件从googledrive传输到我的服务器来处理它们(我的同事不能将它们直接放在服务器上)。它工作得很好,不再工作了。 我正在使用API V3 PHP库。所有文件都组织在给定根目录中的目录中。我很容易列出我的根目录的内容,但是我无法获得每个子文件夹的内容。这是我的密码:Php GoogleDrive API V3:无法列出子文件夹的内容,php,google-drive-api,Php,Google Drive Api,我想将文件从googledrive传输到我的服务器来处理它们(我的同事不能将它们直接放在服务器上)。它工作得很好,不再工作了。 我正在使用API V3 PHP库。所有文件都组织在给定根目录中的目录中。我很容易列出我的根目录的内容,但是我无法获得每个子文件夹的内容。这是我的密码: function upload() { // Get the API client and construct the service object. $client = getClient();
function upload() {
// Get the API client and construct the service object.
$client = getClient();
$service = new Google_Service_Drive($client);
$list=$service->files->listFiles
(array('q' => "mimeType='application/vnd.google-apps.folder' and name='MYROOT'",
'fields' => 'nextPageToken, files(id, name)'));
$publicistRoot=$list->getFiles();
$publicistRoot=$publicistRoot[0];
$publicistRootId=$publicistRoot->getId();
$list=$service->files->listFiles
(array('q' => "mimeType='application/vnd.google-apps.folder' and '$publicistRootId' in parents",
'fields' => 'nextPageToken, files(id, name)'));
foreach($list->getFiles() as $folder) {
// ***** I can list all subdirectories
uploadFolder($service, $folder);
}
}
function uploadFolder(&$service, &$folder) {
$dir="$parentDir/".trim($folder->getName());
mkdir($dir);
$list=$service->files->listFiles
(array('q' => "'".$folder->getId()."' in parents",
'fields' => 'nextPageToken, files(id, name)'));
// ***** here, in $list, the field "nextPageTogen is set to NULL
$toTransfer=$list->getFiles();
if (!count($toTransfer)) {
// ***** there is no files here, although there are some on the google drive
print("Le dossier '".$folder->getName()."' ne contient pas de fichier.\n");
} else {
foreach($toTransfer as $elt) {
// ***** copy contents
}
}
}
有人有主意吗
感谢您的帮助基于此(尽管它很旧),Google Drive不支持在特定文件夹中搜索。如本文所述,您应该能够简单地使用父查询(但使用v2)。基于此(尽管它很旧),Google Drive不支持在特定文件夹中搜索。如本文所述,您应该能够简单地与父查询一起使用(但使用v2)。