ttskch/google-sheets-api-php-client
Composer 安装命令:
composer require ttskch/google-sheets-api-php-client
包简介
PHP client library for Google Sheets API.
关键字:
README 文档
README
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.
统计信息
- 总下载量: 2.35k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-08-23