简体   繁体   English

Google表格中来自我服务器的更新数据

[英]Google Sheet update data from my server

I create a Google Sheet add-on but now I need to update the sheet when there is new update on my server. 我创建了一个Google Sheet加载项,但是现在我需要在服务器上有新更新时更新该表。 I found there are 2 options. 我发现有2个选项。

  1. use installable trigger to periodically pull values from my server. 使用可安装的触发器定期从我的服务器提取值。
  2. use form submit trigger. 使用表单提交触发器。 I'm not sure whether this can be used for pulling data. 我不确定这是否可用于提取数据。

Which is the best option to pull data and update to Google Sheet for a published add-on? 对于已发布的加载项,将数据提取并更新到Google表格的最佳选择是什么?

Google just released Cloud Messaging Pub/Sub. Google刚刚发布了Cloud Messaging Pub / Sub。 This is a tool that covers exactly what you are trying to accomplish. 这是一个涵盖您要完成的任务的工具。

https://cloud.google.com/pubsub/overview https://cloud.google.com/pubsub/overview

Pub/Sub is an API that is designed for application to application messaging. 发布/订阅是一种API,旨在用于应用程序到应用程序的消息传递。 You need to set up your script as a push webhook endpoint. 您需要将脚本设置为推送Webhook端点。 It isn't obvious, nor documented, but I figured it out through exploration. 这不是很明显,也没有记录,但是我通过探索发现了。 This is needed to set up you add-ons and server for push notifications instead of using pulling. 这是设置您的加载项和服务器以进行推送通知所必需的,而不是使用拉动。

  1. Publish your script as a webapp. 将脚本发布为Webapp。
  2. Deploy it to the Chrome Store. 将其部署到Chrome商店。 You do not need to publish so you can leave it in draft. 您无需发布,因此可以将其保留在草稿中。
  3. Get the published WebApp URL. 获取发布的WebApp URL。 It will look something like: 它看起来像:

     https://script.google.com/macros/s/AKfycbx7STHODJlW...EjvowTaO0mmZ3TA9Xsdq1/exec 
  4. Go back the the Developer Console from your script and choose Push under API & Auth. 从脚本返回开发者控制台,然后在API&Auth下选择Push。

  5. Add the domain specific URL without the trailing 'exec' in my case : 在我的情况下,添加域特定的URL而不添加结尾的“ exec”:

     https://script.google.com/macros/s/AKfycbx7STHODJlW...EjvowTaO0mmZ3TA9Xsdq1/ 

The form submit trigger only happens when someone submits a Google Form. 表单提交触发器仅在有人提交Google表单时发生。 I have no idea when and by what event your server is being updated. 我不知道何时以及通过什么事件来更新服务器。

If your server can submit an HTTP Request, you could use a Google Sheets API. 如果您的服务器可以提交HTTP请求,则可以使用Google Sheets API。

https://developers.google.com/google-apps/spreadsheets/ https://developers.google.com/google-apps/spreadsheets/

The installable time trigger would be a lot easier. 可安装的时间触发器将容易得多。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用唯一标识符通过Google Apps脚本根据另一个工作表中的数据更新第一工作表中的数据 - Update data in 1st sheet based on data from another sheet with google apps script via unique identifier 如何从Google表格获取数据到我的Gmail插件 - How to get data from google sheet to my Gmail addon Google表格-如果两个表格中的值都匹配,则使用表格2中的数据更新表格1 - Google Sheets - Update Sheet 1 with data from Sheet 2 if a value on both sheets match 将数据从工作表移动到工作表Google工作表 - move data from sheet to sheet google sheets 根据另一个Google工作表中的值更新Google工作表中的值 - Update values in a google sheet based on values from another google sheet 如何在不使用电子表格 ID 的情况下使用 Google 脚本从另一个 Google 表格导入数据(2020 年 7 月更新停止了我的代码工作) - How to import data from another Google Sheet using Google Script without using Spreadsheet ID (July 2020 update stopped my code working) 未使用 Google 应用程序脚本打开 Google Sheet 时如何更新来自另一个源的导入范围数据 - How to Update Import Range data from another Source when Google Sheet is not open using Google app script 从 python 脚本更新谷歌表 - Update google sheet from python script 谷歌应用脚本从工作表更新表单 - Google app script to update Form from Sheet 将数据从Google表格显示到Google表单中 - Display Data from Google Sheet into Google Forms
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM