Skip to content
PHP client library for Google Sheets API.
Branch: master
Clone or download
Takashi Kanemoto
Latest commit 039ea24 Nov 9, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
demo feat: enable to earn userinfo Nov 9, 2018
src feat: enable to earn userinfo Nov 9, 2018
tests test: fix (unmeaning) test Nov 9, 2018
.gitignore init with koriym/php-skeleton Aug 23, 2017
.php_cs.dist init with koriym/php-skeleton Aug 23, 2017
.scrutinizer.yml init with koriym/php-skeleton Aug 23, 2017
.travis.yml init with koriym/php-skeleton Aug 23, 2017
LICENSE Initial commit Aug 23, 2017
README.md docs: update readme Nov 9, 2018
composer.json first version Aug 23, 2017
phpcs.xml init with koriym/php-skeleton Aug 23, 2017
phpmd.xml init with koriym/php-skeleton Aug 23, 2017
phpunit.xml.dist

README.md

google-sheets-api-php-client

Latest Stable Version Total Downloads

PHP client library for Google Sheets API.

Requirements

  • PHP 5.6+

Installations

$ composer require ttskch/google-sheets-api-php-client:@dev

Usage

Initializing API client

With OAuth2

// 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

// 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

// 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.

You can’t perform that action at this time.