jan*_*eir 7 google-calendar-api google-apps-script
我在Google Apps脚本中有一个日历事件,我希望允许用户通过单击Anchor来打开它.我想我的URL必须如下所示:http://www.google.com/calendar/event?eid = SOMEID>z = Etc/GMT.但是,我似乎无法从日历事件中获取所需的ID.我从Event.getId()获取的ID在这些URL中不起作用,并且没有event.getUrl().
有没有人知道这是否可以使用应用程序脚本?
小智 15
对于CalendarEventevent类型的给定对象并给出,构建URL以在Google Calendar App中查看/编辑相应事件的最简单且有效的方法如下:calendarId
var splitEventId = event.getId().split('@');
var eventURL = "https://www.google.com/calendar/event?eid=" + Utilities.base64Encode(splitEventId[0] + " " + calendarId);
Run Code Online (Sandbox Code Playgroud)
最棒的是,不需要Google API调用,身份验证......
小智 5
好吧……这是 2020 年的工作版本,以防有人仍在为此苦苦挣扎……
var calendarID = "somec@lend.ar";
var event = CalendarApp.getCalendarById(calendarID).createEvent(/*SOME OPTIONS HERE*/);
var splitEventId = event.getId().split('@');
// Open the "edit event" dialog in Calendar using this URL:
var event_EDIT_URL = "https://calendar.google.com/calendar/r/eventedit/" + Utilities.base64Encode(splitEventId[0] + " " + calendarID).replace("==",'');
// Open the "view this event in a Calendar" using this URL:
var event_VIEW_IN_CAL_URL = "https://www.google.com/calendar/event?eid=" + Utilities.base64Encode(splitEventId[0] + " " + calendarID).replace("==",'');
return event_EDIT_URL; // OR return event_VIEW_IN_CAL_URL;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4017 次 |
| 最近记录: |