ソラムギ / google-drive-client-php
0.1.2
2014-08-01 11:25 UTC
Requires
- soramugi/google-api: 0.6.2
Requires (Dev)
- mockery/mockery: 0.7.*
- phpunit/phpunit: 3.7.*
This package is not auto-updated.
Last update: 2024-09-28 14:37:56 UTC
README
用于操作Google Drive API的PHP库。该库是基于以下库的包装器。
https://github.com/bitgandtter/google-api 基于 http://code.google.com/p/google-api-php-client/
安装
使用Composer
composer.json
{ "require": { "soramugi/google-drive-client-php": "*" } }
curl -s http://getcomposer.org/installer | php
php composer.phar install
用法
认证
<?php require_once __DIR__ . '/vendor/autoload.php'; $client = new Soramugi\GoogleDrive\Client; $client->setClientId('your client id'); $client->setClientSecret('your client secret'); $token = '{"access_token":"your_access_token","token_type":"Bearer","expires_in":3600,"refresh_token":"your_refresh_token","created":0000000000}'; $client->setAccessToken($token);
获取客户端ID或客户端密钥。
https://code.google.com/apis/console/
获取json类型的access_token。
https://gist.github.com/soramugi/6060776
列表显示
<?php $files = new Soramugi\GoogleDrive\Files($client); foreach ($files->listFiles()->getItems() as $item) { if (!$item->getLabels()->getTrashed()) { echo "file : {$item->getTitle()}\n"; echo "{$item->getId()}\n"; } }
添加电子表格
$file = new Soramugi\GoogleDrive\Spreadsheet(); $file->setClient($client); $file->setTitle('test file '. time()); $file->setDescription('test description'); $data = "foo,var\nhi"; $createdFile = $file->insert($data); echo $createdFile->getTitle() . "\n";
添加到文件夹时,设置文件夹文件的ID。
$file->setParentId($folderId);
贡献
- 分叉它
- 创建您的功能分支 (
git checkout -b my-new-feature
) - 提交您的更改 (
git commit -am 'Add some feature'
) - 推送到分支 (
git push origin my-new-feature
) - 创建新的Pull Request
许可
Apache许可证,版本2.0