Google-api-php-client: Undefined property: Google_Service_Drive::$parents

Created on 4 Aug 2018  路  1Comment  路  Source: googleapis/google-api-php-client

I'm using the code example from the gdrive docs:
`/**

  • Print a file's parents.
    *
  • @param Google_Service_Drive $service Drive API service instance.
  • @param String $fileId ID of the file to print parents for.
    */
    function printParents($service, $fileId) {
    try {
    $parents = $service->parents->listParents($fileId);
foreach ($parents->getItems() as $parent) {
  print 'File Id: ' . $parent->getId();
}

} catch (Exception $e) {
print "An error occurred: " . $e->getMessage();
}
}`

But I get the error Undefined property: Google_Service_Drive::$parents and I also couldn't find any code referencing parents so is the option to get and list parents removed?

question

Most helpful comment

Right now this client library only supports v3 of the Drive API. You will want to use files.get with ?fields=parents to list parents: https://developers.google.com/drive/api/v3/migration

>All comments

Right now this client library only supports v3 of the Drive API. You will want to use files.get with ?fields=parents to list parents: https://developers.google.com/drive/api/v3/migration

Was this page helpful?
0 / 5 - 0 ratings

Related issues

camohub picture camohub  路  3Comments

upendtu picture upendtu  路  4Comments

Fredyy90 picture Fredyy90  路  3Comments

cmcfadden picture cmcfadden  路  5Comments

ysaurabh33 picture ysaurabh33  路  3Comments