soramugi / google-drive-client-php
Installs: 9 706
Dependents: 0
Suggesters: 0
Security: 0
Stars: 28
Watchers: 4
Forks: 9
Open Issues: 3
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-12-21 15:54:55 UTC
README
The php library to Google Drive API operate. The wrapper which uses the library based on the following library.
https://github.com/bitgandtter/google-api based on http://code.google.com/p/google-api-php-client/
Installation
Using Composer
composer.json
{ "require": { "soramugi/google-drive-client-php": "*" } }
curl -s http://getcomposer.org/installer | php
php composer.phar install
Usage
Attestation
<?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);
get client id or client secret.
https://code.google.com/apis/console/
get json type string access_token.
https://gist.github.com/soramugi/6060776
List display
<?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"; } }
Add Spreadsheet
$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";
When adding into folder, id of forder file is set up.
$file->setParentId($folderId);
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
License
Apache License, Version 2.0