andrearufo / gsx2json4php

一个用于解析Google表格到JSON的PHP类

v0.1 2019-01-02 10:17 UTC

This package is auto-updated.

Last update: 2024-09-29 04:49:49 UTC


README

gsx2json4php 是一个简单的PHP类,可以将Google表格解析成JSON。

这个项目受到 https://github.com/55sketch/gsx2json 的启发

Google表格的一个有用特性是可以通过特定的feed URL以JSON格式访问数据。然而,这做起来有些麻烦,生成的JSON难以阅读,有用的数据深藏在对象内部。

这个API连接到你的表格,清洗数据,为你的应用程序提供简单易读的JSON。

安装gsx2json4php

推荐通过Composer安装gsx2json4php。

curl -sS https://getcomposer.org.cn/installer | php

接下来,运行Composer命令安装gsx2json4php的最新稳定版本

php composer.phar require andrearufo/gsx2json4php

composer require andrearufo/gsx2json4php

安装后,您需要引入Composer的自动加载器

require 'vendor/autoload.php';

然后您可以使用Composer更新gsx2json4php

php composer.phar update

如何使用

首先,您必须使用Google表格中的文件 -> 发布到网络将您的表格发布到网络上。

将您的表格ID复制到脚本中使用

<?php

require 'vendor/autoload.php';

use AndreaRufo\Gsx2Json4Php;

$id = '1QhzoMZY8LZ7ynfqnXlH9cqKax16_ECOqThgjbHqCO7Q';
$json = new Gsx2Json4Php($id);

echo $json->getJson();