我不明白为什么“event”总是返回null,我不确定我做错了什么并且无法在文档中找到任何内容。
var cal_id = "xxxxxxxxxxx@group.calendar.google.com";
var start = new Date();
var calendar = CalendarApp.getCalendarById(cal_id);
var end = new Date(new Date().setFullYear(new Date().getFullYear() + 3));
var calendar = CalendarApp.getCalendarById(cal_id);
var events = calendar.getEvents(start, end);
var event_id = events[0].getId();
var event = calendar.getEventById(event_id)
答案 0 :(得分:0)
我使用var event = events[0];
并且根本不使用getId()
来处理它。最终的代码与此类似:
var cal_id = "xxxxxxxxxxx@group.calendar.google.com";
var start = new Date();
var calendar = CalendarApp.getCalendarById(cal_id);
var end = new Date(new Date().setFullYear(new Date().getFullYear() + 3));
var calendar = CalendarApp.getCalendarById(cal_id);
var events = calendar.getEvents(start, end);
var event = events[0];