Retrieve file metadata from google drive api

By : Luca

I'm working to a web app that let a user see his video files stored on google drive and play them with an html5 player.

I used Google Picker to show user files. When picking a file, the user is redirected to an url like myfile.php?id={file_id}

On the landing page, if I use a code like this below, I receive a 403 error (failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden).

$json = file_get_contents($url);
$data= json_decode($json,true);

Do I need to check again that the user is logged in? If so, which is the quicker way?

By : Luca

If the file is not public (only shared to a specific set of users), the request must contain an authorization header (specifically an OAuth 2.0 header).

I would suggest taking a look at the PHP DrEdit sample code so that you can get familiar with integrating with the Drive web UI, the Picker API and the authorization mechanism.

By : Alain

This video can help you solving your question :)
By: admin