Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Drive API thumbnail parameters

I'm using Google Drive API (v3) with Google's PHP api client to list and display videos from my Drive, where I'm also displaying thumbnails for said videos. I have difficulties getting thumbnail urls back from the API, although I enabled thumbnailLink in request parameters:

'fields' => 'nextPageToken, files(id, name, thumbnailLink, webContentLink, webViewLink)'

Value for thumbnailLink is still empty, other values are returned successfully. I looked for thumbnail settings in api documentation, without success. API also doesn't return any error. What could it be?

Here's the code I'm using:

$drive_service = new Google_Service_Drive($client);

$optParams = array(
'pageSize' => 4,
'q' => "'0B_nSMgQioOWwNy1ha0tFWEE0QWs' in parents and mimeType contains 'video/'",
'fields' => 'nextPageToken, files(id, name, modifiedTime, mimeType, createdTime, thumbnailLink, webContentLink, webViewLink)'
);

return $files_list = $drive_service->files->listFiles($optParams)->getFiles();

and var_dump of response

array(4) {
[0]=>
object(Google_Service_Drive_DriveFile)#590 (56) {
["collection_key":protected]=>
string(6) "spaces"
["appProperties"]=>
NULL
["capabilitiesType":protected]=>
string(42) "Google_Service_Drive_DriveFileCapabilities"
["capabilitiesDataType":protected]=>
string(0) ""
["contentHintsType":protected]=>
string(42) "Google_Service_Drive_DriveFileContentHints"
["contentHintsDataType":protected]=>
string(0) ""
["createdTime"]=>
string(24) "2016-09-12T19:54:22.000Z"
["description"]=>
NULL
["explicitlyTrashed"]=>
NULL
["fileExtension"]=>
NULL
["folderColorRgb"]=>
NULL
["fullFileExtension"]=>
NULL
["headRevisionId"]=>
NULL
["iconLink"]=>
NULL
["id"]=>
string(35) "1St7nQ3X3-ocrMUC2t-r6NOVc4xIdfhbIgg"
["imageMediaMetadataType":protected]=>
string(48) "Google_Service_Drive_DriveFileImageMediaMetadata"
["imageMediaMetadataDataType":protected]=>
string(0) ""
["isAppAuthorized"]=>
NULL
["kind"]=>
NULL
["lastModifyingUserType":protected]=>
string(25) "Google_Service_Drive_User"
["lastModifyingUserDataType":protected]=>
string(0) ""
["md5Checksum"]=>
NULL
["mimeType"]=>
string(9) "video/mp4"
["modifiedByMeTime"]=>
NULL
["modifiedTime"]=>
string(24) "2016-12-27T11:55:43.958Z"
["name"]=>
string(12) "MOV_1950.mp4"
["originalFilename"]=>
NULL
["ownedByMe"]=>
NULL
["ownersType":protected]=>
string(25) "Google_Service_Drive_User"
["ownersDataType":protected]=>
string(5) "array"
["parents"]=>
NULL
["permissionsType":protected]=>
string(31) "Google_Service_Drive_Permission"
["permissionsDataType":protected]=>
string(5) "array"
["properties"]=>
NULL
["quotaBytesUsed"]=>
NULL
["shared"]=>
NULL
["sharedWithMeTime"]=>
NULL
["sharingUserType":protected]=>
string(25) "Google_Service_Drive_User"
["sharingUserDataType":protected]=>
string(0) ""
["size"]=>
NULL
["spaces"]=>
NULL
["starred"]=>
NULL
["thumbnailLink"]=>
NULL
["trashed"]=>
NULL
["version"]=>
NULL
["videoMediaMetadataType":protected]=>
string(48) "Google_Service_Drive_DriveFileVideoMediaMetadata"
["videoMediaMetadataDataType":protected]=>
string(0) ""
["viewedByMe"]=>
NULL
["viewedByMeTime"]=>
NULL
["viewersCanCopyContent"]=>
NULL
["webContentLink"]=>
string(82) "https://drive.google.com/uc?id=1St7nQ3X3-ocrMUC2t-r6NOVc4xIdfhbIgg&export=download"
["webViewLink"]=>
string(85) "https://drive.google.com/file/d/1St7nQ3X3-ocrMUC2t-r6NOVc4xIdfhbIgg/view?usp=drivesdk"
["writersCanShare"]=>
NULL
["internal_gapi_mappings":protected]=>
array(0) {
}
["modelData":protected]=>
array(0) {
}
["processed":protected]=>
array(0) {
}
}...
like image 813
boogysi Avatar asked Oct 29 '22 14:10

boogysi


1 Answers

Try to double check if you properly use a correct scope. I suggest you to use the https://www.googleapis.com/auth/drive for full permissive scope to access all of a user's files. If it's still not working, then try the suggested solution here.

like image 83
KENdi Avatar answered Nov 15 '22 05:11

KENdi