stopsopa/google-spreadsheets-api-extension 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

stopsopa/google-spreadsheets-api-extension

Composer 安装命令:

composer require stopsopa/google-spreadsheets-api-extension

包简介

My own approach to manipulating data in Google Spreadsheets

README 文档

README

Build Status Latest Stable Version Coverage Status License

DEPRECATED

Created in 2016 - quite old now and not maintained.

stopsopa/google-spreadsheets-api-extension

Instalation

Follow packagist instructions: Packagist

Setup access to google spreadsheet documents

First You need to generate credentials in Google API Console and setup Service account keys (read more). After that you recieve file '.p12' which is a private key and special e-mail address (eq: applicationname@applicationname.iam.gserviceaccount.com) that you should use to give access to api to specific spreadsheets in google-drive.

Setup this library

use Stopsopa\GoogleSpreadsheets\Services\GoogleSpreadsheets;

$service = new GoogleSpreadsheets();

$service->setupByServiceAccountKey(
    'pathtofile.p12', 
    'applicationname@applicationname.iam.gserviceaccount.com'
);

... and now you are ready to go.

Api

Most of methods is pretty self-explanatory so normally you can explore them through IDE or just by exploring returned data structures (especially if you read terminology used in Sheets API), they don't need to be explained here in details, but it is also good thing to list them here. It is also good idea to see tests starting from method testFindWorksheets.

Methods of GoogleSpreadsheets class

Method with default parameters Returned type Additional description
$service->findSpreadsheets($rawResponse = false); array
$service->findWorksheets($key, $rawResponse = false); array
$service->getWorksheetMetadata($key, $wid); array
$service->updateWorksheetMetadata($key, $wid, $title = null, $rows = null, $cols = null); array
$service->findWorksheetData($key, $wid, $rawResponse = false, $filter = array()); array
$service->deleteWorksheet($key, $wid); array
$service->update($key, $wid, $data); array doc
$service->findFirstFreeRowForData($key, $wid); int (1 indexed)
$service->getList($key, $wid); GoogleSpreadsheetsList

Methods of GoogleSpreadsheetsList class

Read more about list based feed.

Method with default parameters Returned type Additional description
$list->add($data); array doc
$list->update($row, $data); array $row is 1 indexed, $data format like above
$list->get($filters = null); array $filters format see this.
Usually use only min-row, max-row.

Commonly used parameters

$rawResponse:

Many of this methods has special parameter $rawResponse, setting up this to true turns returned data structure to raw form, just like it's comes from google api. But in most cases it is better to leave this parameter as is and get more consist and better to iterate through data structure at the output of this methods.

$key

You can find the key in the spreadsheet URL (bolded in below example).

https://docs.google.com/spreadsheets/d/1IAP4HOacD4Az6q_PFfxxxxxxxxxxxxxxxx9KBX-IMO25s/edit?usp=sharing

$wid

This is unique identifier for each worksheet in spreadsheet, You can get these ids by using method findWorksheets.

$filter

This parameter is used to fetch specific rows or columns ranges from worksheet, eq:

  $result = $service->findWorksheetData($key, $wid, false, array(
    'max-col' => 4,
    'max-row' => 3
  ));

For more informations see in google api Fetch specific rows or columns.

Other details

Method GoogleSpreadsheets->update()

    $service->update($key, $wid, array(
        'A1' => "Name",
        'B1' => "Surname",
        'C1' => "Age",
        'D1' => "Weight",
        'E1' => "Height",
        'A2' => "Something else... ",
        'R2C5' => "And again...",
        'R3C2' => '' // empty string to delete value from cell
    ));

Using this method you can use two types of positioning notations. Using method update you can set/update/delete data in many cells by one batch request.

To convert in both ways these two types of formats use this lib.

Method GoogleSpreadsheetsList->add()

    $list->add(array(
        'Name' => 'John',
        'Surname' => 'Smith',
        'Age' => '35'
    ));

To read more about basic assumptions that describes working with list based feeds go here.

License

The MIT License (MIT) Copyright (c) 2016 Szymon Działowski Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

stopsopa/google-spreadsheets-api-extension 适用场景与选型建议

stopsopa/google-spreadsheets-api-extension 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 04 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 stopsopa/google-spreadsheets-api-extension 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 stopsopa/google-spreadsheets-api-extension 我们能提供哪些服务?
定制开发 / 二次开发

基于 stopsopa/google-spreadsheets-api-extension 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 17
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-04-01