I have this code from google:
function retrieveAllFiles($service) {
$result = array();
$pageToken = NULL;
do {
try {
$parameters = array();
if ($pageToken) {
$parameters['pageToken'] = $pageToken;
}
$files = $service->files->listFiles($parameters);
$result = array_merge($result, $files->getItems());
$pageToken = $files->getNextPageToken();
} catch (Exception $e) {
print "An error occurred: " . $e->getMessage();
$pageToken = NULL;
}
} while ($pageToken);
return $result;
}
I know i can do this:
$files = retrieveAllFiles($service);
foreach($files as $file){
$id = $file->getId();
$title = $file->getTitle()
}
We can also fetch the parents of the file by:
foreach($files as $file){
$parents = $file->getParents();
}
Is it possible to get the titles of the parent folders without calling another request? like:
foreach($files as $file){
$parents = $file->getParents();
foreach($parents as $parent){
$parent_title = $parent->getTitle(); //NOT EXISTING
}
}
I know that it throws an error but is there other alternative to achieve this requirement?