简体   繁体   English

如何使用PHP从我自己的网站上获取Google云端硬盘中的文件和文件夹列表?

[英]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. 我已经设置了Google的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. 您可以使用此处详细介绍的Google自己的示例该示例将指导您完成此操作的整个过程。

Once you have authentication complete, you can do the following: Register for an API key here . 完成身份验证后,您可以执行以下操作: 在此处注册API密钥。

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 . 您现在可以使用PHP中的cURLfile_get_contents()将HTTP GET请求发送到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. 对页面的AJAX请求不起作用,因为页面不是您域的一部分。 You need to send your requests with the following parameters. 您需要使用以下参数发送请求。

maxResults integer Maximum number of files to return. maxResults integer要返回的最大文件数。

pageToken string Page token for files. pageToken string文件的页面标记。

q string Query string for searching files. q string搜索文件的查询字符串。

The final request might look like 最终的请求可能看起来像

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

Link: Documentation 链接: 文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Google云端硬盘中的PHP SDK访问我自己的文件? - How to get access to my own files using PHP SDK in Google Drive? 无法使用php从Google驱动器获取文件列表 - Can't get list of files from google drive using php 使用 PHP,如何“在文件夹之间插入和移动文件”从 Google Cloud Platform 到 Google Drive? - Using PHP, how do I "Insert and move files between folders" from Google Cloud Platform to Google Drive? 如何使用 PHP 和 Google Drive API 获取基于所有者的所有文件夹和文件 - How to get all folders & files based on Owner using PHP with Google Drive API 如何连接谷歌驱动器并获取列表文件夹并使用php排列为树? - How to connect google drive and get list folders and arrange as a tree using php? 在 PHP 中从 Google Drive v2 获取文件列表 - Get list of files from Google Drive v2 in PHP 我无法使用php在我的Google云端硬盘中看到通过api创建的文件和文件夹 - I can't see the files and folders created via api in my Google Drive using php 使用PHP的Google云端硬盘文件列表 - Google Drive files list using PHP 列出Google Drive SDK中的所有文件夹及其文件 - List All Folders and their files in Google Drive SDK 如何使用 Google Drive API 上传我的 Drive (PHP) 中的文件? - How to use Google Drive API to upload files in my Drive (PHP)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM