2017-07-20 108 views
1

我想从其他用户创建的公开共享Google SpreadSheets中获取JSON数据。如何从谷歌电子表格中获取json数据

要调用API我用下面的URL格式:https://spreadsheets.google.com/feeds/list/[sheet_id]/[tab_id]/public/basic?alt=json

但是,当我设置从一个我从一个共享的链接获得sheet_id我收到404响应。 :-(

enter image description here

顺便说一句,我可以从同一个共享链接获取JSON数据,如果我把它公开在网络上

这样的:

enter image description here

我可以从另一个用户共享链接获取json数据吗?

这是我的申请条件

  1. 共享链接可以从许多人发送。
  2. 这些链接不公开到网络。
  3. 我从共享链接制作sheet_id并调用api。
  4. 我从API响应数据运行应用程序。

感谢您的耐心等待,请原谅我可怜的英语。

+0

您可以共享示例共享链接和完整的HTTP请求吗? – smarx

+0

这可能会给你一些方向https://stackoverflow.com/questions/30082277/accessing-a-new-style-public-google-sheet-as-json,我想获得一个私人工作表数据,你需要认证。 – gusaindpk

+0

@smarx谢谢!这是示例网址! https://docs.google.com/spreadsheets/d/1TlGL9JASdAidux2xAMKKbWOeMEAJswzRUdp4cWqnDzg/edit?usp=sharing –

回答

1

我不确定您使用的是什么API方法,但是这似乎在您给出的示例电子表格上正常工作。 (请确保包含您的API密钥。)

GET https://sheets.googleapis.com/v4/spreadsheets/1TlGL9JASdAidux2xAMKKbWOeMEAJswzRUdp4cWqnDzg/values/texts?key=<REDACTED>