laraditz/google-sheets

Google Sheets API V4包装器

1.0.0 2022-09-20 09:07 UTC

This package is auto-updated.

Last update: 2024-09-20 13:21:00 UTC


README

Latest Version on Packagist Total Downloads GitHub Actions

Google Sheets API V4的简单包装器。

安装

您可以通过composer安装此包

composer require laraditz/google-sheets

设置

  1. 此API使用服务帐户进行身份验证。请按照说明创建服务帐户
  2. 下载JSON凭证。
  3. 默认情况下,凭证的路径位于storage app/credentials.json。您可以通过覆盖GOOGLE_SHEETS_AUTH_CONFIG环境变量来设置自己的路径。
  4. 还有其他可以覆盖以适应您需求的.env值,如下所示:
GOOGLE_SHEETS_APP_NAME="Google Sheets"
GOOGLE_SHEETS_ACCESS_TYPE=offline
GOOGLE_SHEETS_AUTH_CONFIG="app/credentials.json"

使用方法

$spreadsheetId = "XXxXXxXXXXXx_XXxXXxXXXXXx_XXxXXxXXXXXx"; // this will be your spreadsheet ID
$range = "Sheet 1"; // here we use the name of the Sheet to get all the rows

// read all the rows of given sheet, sheet will return a Collection and you may use any of Collection method such as all(), toArray(), etc
$sheets = app('google-sheets')->spreadsheet($spreadsheetId)->sheet($range)->all();

测试

composer test

变更日志

请参阅CHANGELOG以获取有关最近更改的更多信息。

贡献

请参阅CONTRIBUTING以获取详细信息。

安全

如果您发现任何安全问题,请通过电子邮件raditzfarhan@gmail.com联系,而不是使用问题跟踪器。

致谢

许可证

MIT许可证(MIT)。请参阅许可证文件以获取更多信息。

包依赖

此包依赖于https://github.com/googleapis/google-api-php-client