How to list files in a specific folder in Google Drive API v3 PHP

Bjørson Ålmer picture Bjørson Ålmer · Feb 5, 2017 · Viewed 19k times · Source

I am searching for a way, how can I list files in a specific folder (with folder id) in Google Drive API v3. I used this function $service->files->listFiles() but It return all files in google Drive. Do you know which function can I use?

Answer

Bjørson Ålmer picture Bjørson Ålmer · Feb 5, 2017

cool I found the answer.

  $optParams = array(
        'pageSize' => 10,
        'fields' => "nextPageToken, files(contentHints/thumbnail,fileExtension,iconLink,id,name,size,thumbnailLink,webContentLink,webViewLink,mimeType,parents)",
        'q' => "'".$folderId."' in parents"
        );
  $results = $service->files->listFiles($optParams);