0
votes

I have a folder in my google drive and I want to list its files and subfolders using google drive Api through a search box. Does Api provide any flexibility to get folders.

I've a script to get folders but it's not working properly. Showing some trashed folder. I want files too.

   $this->client = $googl->client();
   $this->drive = $googl->drive($this->client);
   $folderId = '0B4JDg65OBlTM3RseUk';
   $parameters = [
            'q' => "'$folderId' in parents",
            'fields' => 'files(id, name, modifiedTime, iconLink, 
             webViewLink, webContentLink)'];
   $result = $this->drive->files->listFiles($parameters);
1
What exactly isn't 'working properly'? Does it run? Does it crash? Does it produce errors, and if so what error? It's hard for people to help you if you don't describe WHAT is going wrong.Teun van der Wijst
Well it's showing some folders that are in trashed. But I want to list all the files in folder.Muhammad

1 Answers

0
votes

To list files, you may use the files.list method of the API. This method accepts the q parameter, which is a search query combining one or more search terms.

Response:

{
  "kind": "drive#fileList",
  "nextPageToken": string,
  "incompleteSearch": boolean,
  "files": [
    files Resource
  ]
}

Example for files.list:

Search for the ID 1234567 in the parents collection. This finds all files and folders located directly in the folder whose ID is 1234567.

'1234567' in parents

To see the valid search parameters, you may visit this link.