bre*_*dan 5 events calendar google-calendar-api google-apps-script
在 Google Apps 脚本中使用高级日历 API 服务 ( https://developers.google.com/apps-script/advanced/calendar ),我发现您可以在更新日历时调用事件处理函数 (参见屏幕截图),并且效果很好:每次添加或更改事件时,似乎都会调用我的函数。但是我无法弄清楚哪个日历事件(即约会)已被修改。使用 1 arg (e) 调用处理函数,该函数的类型为“event”,但它似乎不包含 ID 或对已更新的日历事件的任何引用。这是我的处理程序代码:
function triggeredOnUpdate(e){
Logger.log('Update event: %s', e);
var calendarId = 'primary';
var eventId = e.<????what goes here???>;
var event = Calendar.Events.get(calendarId, eventId);
Logger.log('Running update on Calendar Event: %s', event.summary);
colourEvent(calendarId, event);
}
Run Code Online (Sandbox Code Playgroud)
并且日志输出为:
更新事件:{authMode=FULL,calendarId=mycalendar@mydomain.com,triggerUid=1325034127}
该 TriggerUID 是触发器的 ID,因此每次调用该处理程序时它都是相同的。
您知道如何找到已更新的日历事件吗?
(注意:当谈论日历中的触发器时,“事件”一词被重载:有一个日历事件,例如约会,以及当约会更改时的更新事件)
] 1
小智 4
按照以下工作流程获取事件 ID: https ://developers.google.com/apps-script/guides/triggers/events#eventupdated
总之:Calendar.Events.list与您在函数参数中获得的日历地址一起使用来执行完全同步,其中包括nextSyncToken可以保存在脚本属性中的同步。
下次触发事件时,您可以通过提供nextSyncTokento来执行增量同步Calendar.Events.list。这将为您提供自上次同步以来的事件。
另请参阅: https: //developers.google.com/calendar/v3/reference/events/list https://developers.google.com/calendar/v3/reference/events#resource
https://developers.google.com/apps-script/advanced/calendar
| 归档时间: |
|
| 查看次数: |
1947 次 |
| 最近记录: |