我想将文件从googledrive传输到我的服务器来处理它们(我的同事不能将它们直接放在服务器上)。它工作正常,它不再起作用了。 我正在使用API V3 PHP库。所有文件都在给定根目录中的目录中进行组织。我很容易列出我的root的内容,但是我无法获得每个子文件夹的内容。这是我的代码:
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
}
}
}
有人有想法吗?
感谢您的帮助