如何添加添加“邀请我" Google日历中的链接 [英] How to add add "Invite Me" link in Google Calendar

查看:257
本文介绍了如何添加添加“邀请我" Google日历中的链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现有人在Google日历中添加了邀请我"链接,如下所示.我已尽力而为,但是当有人单击事件时找不到添加此链接的方法.

I've found someone adding "Invite Me" link in the Google Calendar as shown below. I've tried my best but could not find a way to add this link when someone clicks on an event.

推荐答案

Molk是正确的,您将需要setAnyoneCanAddSelf(true).

Molk is correct, you will need to setAnyoneCanAddSelf(true).

我将如何将其部署为一个Web应用程序,该脚本将获取日历事件ID(Session.getActiveUser().getEmail())的查询参数,并将其添加到日历事件中.我将在主日历的描述"字段中创建URL(如您的屏幕快照一样,使用已部署的脚本URL的URL并为id添加查询参数.

How I would go about it is deploying a script as a web app that takes a query parameter for the calendar event id, the Session.getActiveUser().getEmail(), and add them to the calendar event. I would create the URL in the primary calendar's Description field (like your screenshot, with the url to the deployed script url and adding the query parameter for the id.

一个例子看起来像这样:

An example would look something like this:

var calId = 'yourdomain.com_459nd7pqmn5irsqgn8p91febe4@group.calendar.google.com';

function inviteMe(){
  try{
    var cal = CalendarApp.getCalendarById(calId);
    var start = new Date();
    var end = new Date();
    start.setHours(13);
    end.setHours(14);

    var event = cal.createEvent("Add Me Test", start,end);
    event.setAnyoneCanAddSelf(true);
    var eventId = event.getId();
    var urlString = '<a href="' + ScriptApp.getService().getUrl() +'?eId=' + eventId + '" target="_blank">Invite Me</a>';
    var desc ='Event details';
    desc += '\n\n' + urlString;
    // now that we have the url built out, add the description
    event.setDescription(desc);
  }catch(err){
    Logger.log(err.lineNumber + ' - ' + err);
    ;
  }
}

function doGet(event){
  try{
    // shorten the event parameter path;
    var param = event.parameter;
    // get the calendar event id passed in the query parameter
    var eventId = param.eId;
    var cal = CalendarApp.getCalendarById(calId);
    var guest = Session.getActiveUser().getEmail();

    var event = cal.getEventSeriesById(eventId);
    event.addGuest(guest);

    return ContentService.createTextOutput("You have been added to the event: " +         event.getTitle());
  }catch(err){
    Logger.log(err.lineNumber + ' - ' + err);
  }
}

看起来像这样: 在活动详细信息中,单击邀请我"链接

And how it would look would be something like this: In the event details, click the invite me link

处理后,使用ContentService显示通知.

Once Processed, use ContentService to display a notice.

最后在用户日历中看到日历

And finally see the calendar in the users calendar

事件所有者将不会在其描述区域中看到该链接,而只会看到原始html锚文本(请参见下面的屏幕截图). Google日历为其他所有人呈现链接;我假定为便于编辑,因为description字段只是一个textarea输入,没有WYSIWYG控件.

The event owner will not see the link in their description area, only the raw html anchor text (see screenshot below). Google Calendar renders the link for everyone else; I assume for ease of editing, since the description field is just a textarea input, with no WYSIWYG controls.

这篇关于如何添加添加“邀请我" Google日历中的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆