每次我受邀参加日历活动时都会进行 Webhook

发布于 2025-01-16 09:09:36 字数 325 浏览 2 评论 0原文

我有一个 Google Workspace 电子邮件地址,每次有人邀请我的地址参加活动时,我都希望获得一个网络钩子。这可能吗?

查看了 Google Calendar API 上的推送通知页面,但找不到我要查找的内容: https://developers.google.com/calendar/api/guides/push

我总是可以解析收到的邀请电子邮件,但想知道是否有办法设置网络钩子,

谢谢

I have a Google Workspace Email address, and I'd like to get a webhook every time someone invites my address to an event. Is this possible?

Had a look at the Push notifications page on the Google Calendar API but I could not find what I was looking for: https://developers.google.com/calendar/api/guides/push

I can always parse the invitation email I receive but wondering if there's a way to set up a webhook

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

看海 2025-01-23 09:09:37

要请求推送通知,您需要为您想要观看的每个资源设置一个通知通道。

首先,您需要一个端点来接收通知,您可以使用 Google Apps 脚本来执行此操作,如下所述 此处

获得有效网址后,您只需使用 Google Calendar API 作为高级服务 Google Apps 脚本内(这是使用 Google Apps 脚本的示例,但这可以用任何语言或使用纯 HTTP 请求重现):

const watchCalendarEvent = () => {
  const channel = Calendar.Events.watch(
    {
      address: "https://mywebapp.com/recieve_calendar_notification",
      id: Utilities.getUuid(),
      type: "web_hook",
    },
    /* This is a keyword for our main calendar */
    /* But you can use whatever you need */
    "primary",
    {
      /* These are not required */
      token: Utilities.getUuid(),
      expiration: Date.now() + 10e5,
    }
)}

之后,您可以转到端点并检查一切是否按预期进行。

To request push notifications, you need to set up a notification channel for each resource you want to watch.

First of all you need an endpoint to receive the notification, you can use Google Apps Script for doing so as described here.

After having a valid URL, you only need to use Google Calendar API as an Advanced Service inside Google Apps Script (this is an example using Google Apps Script, but this can be reproducible in any language or using pure HTTP request):

const watchCalendarEvent = () => {
  const channel = Calendar.Events.watch(
    {
      address: "https://mywebapp.com/recieve_calendar_notification",
      id: Utilities.getUuid(),
      type: "web_hook",
    },
    /* This is a keyword for our main calendar */
    /* But you can use whatever you need */
    "primary",
    {
      /* These are not required */
      token: Utilities.getUuid(),
      expiration: Date.now() + 10e5,
    }
)}

After that, you can go to your endpoint and check if everything is going as expected.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文