仅使用Apps脚本获取特定日历活动的完整ID

时间:2018-01-29 15:39:39

标签: google-apps-script calendar

我想生成一个指向公共活动的HTML链接,以便有人可以点击它并直接将其带到谷歌日历中。

以下是一个例子:link to a specific public calendar event

我知道格式如下

https://www.google.com/calendar/event?eid={event-id}&ctz={timezone}

问题是here previously,但答案需要启用高级服务并使用日历api,这似乎有点过分来检索完整的事件ID。

真的没有办法只使用应用脚本来获取完整ID吗?

谢谢!

1 个答案:

答案 0 :(得分:0)

我找到了答案。我是开发新手,所以可能有更好的方法来写这个。

function createEvent(){
var stringId = 'insertYourCalId';
var calendar = CalendarApp.getCalendarById(stringId);
var event = calendarId.createEvent(title, eventStart, eventEnd);
var eventId = event.getId().split("@")[0].toString();
var eventLink = Calendar.Events.get(stringId, eventId).htmlLink;
}