我正在尝试在Google云端硬盘中下载与我共享的特定文件。我开发了脚本来获取帐户中文件和文件夹的列表。在该文件夹中,我需要获取文件列表。尝试执行此操作时,出现以下错误,
Notice: Undefined property: Google_Service_Drive::$children
我的代码:
$client = new Google_Client();
$client->setApplicationName('Google Drive API');
$client->setScopes(Google_Service_Drive::DRIVE);
$client->setAuthConfig('credentials.json');
$client->setAccessType('offline');
$service = new Google_Service_Drive($client);
$optParams = array(
"pageSize" => 10,
"fields" => "nextPageToken, files(id, name)",
"q" => "sharedWithMe and name contains 'Folder Name'"
);
$results = $service->files->listFiles($optParams);
if (count($results->getFiles()) == 0) {
print "No files found.\n";
} else {
print "Files:\n";
foreach ($results->getFiles() as $files) {
printf("%s (%s)\n", $files->getName(), $files->getId());
$folderId = $files->getId();
$parameters = array();
$children = $service->children->listChildren($folderId, $parameters);
}
}
我需要文件夹中的fileId,所以我可以下载它。
让我知道我的代码是否缺少范围或任何错误。
您的建议将非常有帮助。
谢谢。