[英]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个选项。
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.
这是设置您的加载项和服务器以进行推送通知所必需的,而不是使用拉动。
Get the published WebApp URL. 获取发布的WebApp URL。 It will look something like:
它看起来像:
https://script.google.com/macros/s/AKfycbx7STHODJlW...EjvowTaO0mmZ3TA9Xsdq1/exec
Go back the the Developer Console from your script and choose Push under API & Auth. 从脚本返回开发者控制台,然后在API&Auth下选择Push。
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.