简体   繁体   中英

How to get list of files and folders from Google Drive on my own website using PHP?

I have a case where i need to display user's google drive data on my own website. how to do this. i have setup Google's Example DriRdit.

The first step is authentication. You can use Google's own example detailed here which runs you through the entire procedure of doing that.

Once you have authentication complete, you can do the following: Register for an API key here .

You can now send an HTTP GET request using cURL or file_get_contents() in PHP to the URL https://developers.google.com/drive/v2/files/list . An AJAX request to the page wouldn't work as the page wouldn't be a part of your domain. You need to send your requests with the following parameters.

maxResults integer Maximum number of files to return.

pageToken string Page token for files.

q string Query string for searching files.

The final request might look like

file_get_contents("https://developers.google.com/drive/v2/files/list?maxResults=".$maxResults."&pageToken=".$pageToken");

Link: Documentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM