divinityfound/googledrivetree

此包最新版本(dev-master)没有提供许可证信息。

将 Google Drive 文件夹编译成一个类似树的数组结构。

dev-master 2015-10-19 20:08 UTC

This package is not auto-updated.

Last update: 2024-09-18 09:41:35 UTC


README

##Google Drive Tree ###将 Google Drive 转换为数组树

此解决方案是为了让开发者更容易地了解 Google Drive 文件映射的全貌,无论是公开还是私人使用。

###Google 设置

  1. 访问 https://console.developers.google.com/project
  2. 创建一个项目。
  3. 在左侧菜单中,展开 "APIs & auth",选择 APIs
  4. 在 Google Apps APIs 下选择 Drive API
  5. 启用 API
  6. 在左侧菜单下 "APIs & auth",选择凭据
  7. 在 OAuth 下,点击 "创建新的客户端 ID"
  8. 点击服务账户,选择 P12 密钥
  9. 将 P12 密钥保存在安全的地方
  10. 访问 https://admin.google.com
  11. 点击 "安全"。它可能位于 "更多显示" 之下。
  12. 在安全中,点击 "更多显示",然后点击 "高级设置"。
  13. 点击 "管理 API 客户端访问"。
  14. 在客户端名称下插入服务账户的客户端 ID,在 API 范围中插入 "https://www.googleapis.com/auth/drive"
  15. 您的 API 现已设置完毕!

###代码

	require_once(__DIR__ . '/../vendor/autoload.php');

	$params = array();
	$params['client_id']            = 'xyz.apps.googleusercontent.com';
	$params['service_account_name'] = 'xyz@developer.gserviceaccount.com';
	$params['key']                  = 'your_directory.P12';
	$params['sub']                  = 'youremail@example.com';
	$params['drive']				= 'drive_folder';

	$data = new \Divinityfound\GoogleDriveTree\Processor($params);

	echo '<pre>';
	print_r($data->file_tree);
	echo '</pre>';
	exit;