Google 日历手表:如何获取已更改的活动的详细信息

问题描述 投票:0回答:1

我有一个应用程序可以为用户管理日历。最初,我通过在接下来的两个月内获取用户的单个事件来设置此功能。 (这让我不必处理重复发生的事件,我只需单独获取每个事件)。 我为用户设置了手表。但是,监视事件的请求根本不包含事件详细信息。我期望在请求正文中出现此内容,但请求正文为空。 我如何接收发生更新的事件详细信息:

Request headers {
  'x-real-ip': '---',
  'x-goog-resource-uri': 'https://www.googleapis.com/calendar/v3/calendars/[[calendarId]]/events?alt=json',
  'x-goog-resource-state': 'exists',
  'x-goog-resource-id': '[[resourceId]]',
  'x-goog-message-number': '1015021',
  'x-goog-channel-id': '6673183088affefaa7ef3081',
  'x-goog-channel-expiration': 'Wed, 26 Jun 2024 19:27:48 GMT',
  'x-forwarded-server': '5fdoa23',
  'x-forwarded-proto': 'https',
  'x-forwarded-port': '443',
  'x-forwarded-host': 'webhook.loca.lt',
  'x-forwarded-for': '...ipaddress...',
  'accept-encoding': 'gzip, deflate, br',
  accept: '*/*',
  'content-length': '0',// request body is empty, i guess
  'user-agent': 'APIs-Google; (+https://developers.google.com/webmasters/APIs-Google.html)',
  host: '<server>',
  connection: 'close',
  'x-clerk-auth-status': 'signed-out',
  'x-clerk-auth-token': '',
  'x-clerk-auth-message': '',
  'x-clerk-auth-reason': 'header-missing-non-browser',
  'x-middleware-invoke': '',
  'x-invoke-path': '/api/calendars/[calendarId]/webhook',
  'x-invoke-query': '%7B%7D',
  'x-invoke-output': '/api/calendars/[calendarId]/webhook'
}
REQUEST BODY: 
(empty)
Query: 
{ calendarId: 'calendarIdInternal' }

如果请求正文应该为空,我必须在接下来的两个月内进行完整的重新获取。对于主动更改日历的用户来说,这可能会变得昂贵。

我想到了使用syncToken,但由于我使用的是单个事件,即使有一个重复事件,它们的事件也会永远循环。我永远不会真正获得同步令牌

google-calendar-api
1个回答
0
投票

似乎唯一的方法是从事件 API 获取详细信息。监视通知请求不包含有关更改内容的任何信息。您可以使用同步令牌并将其存储在数据库中,并使用它仅获取自上次同步以来的更改。

© www.soinside.com 2019 - 2024. All rights reserved.