Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ttskch/google-sheets-api-php-client
PHP client library for Google Sheets API.
https://github.com/ttskch/google-sheets-api-php-client
api-client google-sheets spreadsheets
Last synced: 3 months ago
JSON representation
PHP client library for Google Sheets API.
- Host: GitHub
- URL: https://github.com/ttskch/google-sheets-api-php-client
- Owner: ttskch
- License: mit
- Created: 2017-08-23T10:52:13.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-09T08:14:15.000Z (about 6 years ago)
- Last Synced: 2024-10-08T13:21:53.253Z (4 months ago)
- Topics: api-client, google-sheets, spreadsheets
- Language: PHP
- Size: 14.6 KB
- Stars: 7
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# google-sheets-api-php-client
[![Latest Stable Version](https://poser.pugx.org/ttskch/google-sheets-api-php-client/v/stable)](https://packagist.org/packages/ttskch/google-sheets-api-php-client)
[![Total Downloads](https://poser.pugx.org/ttskch/google-sheets-api-php-client/downloads)](https://packagist.org/packages/ttskch/google-sheets-api-php-client)PHP client library for Google Sheets API.
## Requirements
- PHP 5.6+
## Installations
```bash
$ composer require ttskch/google-sheets-api-php-client:@dev
```## Usage
### Initializing API client
#### With OAuth2
```php
// create \Google_Client instance with your OAuth2 client ID.
$googleClient = \Ttskch\GoogleSheetsApi\Factory\GoogleClientFactory::createOAuthClient(
'client_id',
'client_secret',
'redirect_uri',
'javascript_origin'
);// authenticate and be athorized.
$authenticator = new \Ttskch\GoogleSheetsApi\Authenticator($googleClient);
if (isset($_GET['code'])) {
$authenticator->authenticate($_GET['code']);
} else {
$authenticator->authorize();
}
```#### With Service Account
```php
// create \Google_Client instance with your Service Account credentials json file.
$googleClient = \Ttskch\GoogleSheetsApi\Factory\GoogleClientFactory::createServiceAccountClient('/path/to/service-account-credentials.json');
```### Using API
```php
// create API client with authorized \Google_Client.
$api = \Ttskch\GoogleSheetsApi\Factory\ApiClientFactory::create($googleClient);$service = $api->getGoogleService();
// now you can call all apis via $service.
// see \Google_Service_Sheets class to learn more about details.
$service->spreadsheets->...;
$service->spreadsheets_sheets->...;
$service->spreadsheets_values->...;
```See also [demo](demo).