我正在尝试创建一个NodeJS API来向Google日历添加事件。该活动将添加到日历中,但与会者未收到邀请电子邮件。但是,组织者会在活动开始前1天收到电子邮件(提醒时间设置)。 这是我的代码
exports.setCalendar = function(request,response){
var addEventBody = {
'status':'confirmed',
'summary': 'Google I/O 2015',
'description': 'A chance to hear more about Google developer products.',
'sendNotifications': true,
'organizer': {
'email': 'sujith@toobler.com',
'self': true
},
'start': {
'dateTime': request.body.startdate,
},
'end': {
'dateTime': request.body.enddate
},
'attendees': [
{
'email': 'sujith@toobler.com',
'organizer': true,
'self': true,
'responseStatus': 'needsAction'
},
{
'email': request.body.contact.email,
'organizer': false,
'responseStatus': 'needsAction'
}
],
'reminders': {
'overrides':[
{
'method' : 'email',
'minutes' :'1440'
},
{
'method' : 'popup',
'minutes' :'1440'
}
],
'useDefault': false
},
'gadget': {
'display' : 'icon',
'title' : 'titleee',
'iconLink' : 'https://image.freepik.com/free-icon/medical-samples-in-test-tubes-couple_318-61810.jpg'
}
};
var addGoogleEvent = function(accessToken){
//instantiate google calendar instance
var google_calendar = new gcal.GoogleCalendar(accessToken);
google_calendar.events.insert('sujith@toobler.com', addEventBody, function(addEventError, addEventResponse){
console.log('GOOGLE RESPONSE:', addEventError, addEventResponse);
if(!addEventError)
return response.send(200, addEventResponse);
return response.send(400, addEventError);
});
};
addGoogleEvent(req.body.accToken);
}
答案 0 :(得分:0)
得到了答案。 sendNotification密钥将作为单独的参数发送,而不是作为数据发送。
exports.setCalendar = function(request,response){
var option = {
'sendNotifications' : true
};
var addEventBody = {
'status':'confirmed',
'summary': 'Google I/O 2015',
'description': 'A chance to hear more about Google developer products.',
'organizer': {
'email': 'sujith@toobler.com',
'self': true
},
'start': {
'dateTime': request.body.startdate,
},
'end': {
'dateTime': request.body.enddate
},
'attendees': [
{
'email': 'sujith@toobler.com',
'organizer': true,
'self': true,
'responseStatus': 'needsAction'
},
{
'email': request.body.contact.email,
'organizer': false,
'responseStatus': 'needsAction'
}
],
'reminders': {
'overrides':[
{
'method' : 'email',
'minutes' :'1440'
},
{
'method' : 'popup',
'minutes' :'1440'
}
],
'useDefault': false
},
'gadget': {
'display' : 'icon',
'title' : 'titleee',
'iconLink' : 'https://image.freepik.com/free-icon/medical-samples-in-test-tubes-couple_318-61810.jpg'
}
};
var addGoogleEvent = function(accessToken){
//instantiate google calendar instance
var google_calendar = new gcal.GoogleCalendar(accessToken);
google_calendar.events.insert('sujith@toobler.com', addEventBody,option, function(addEventError, addEventResponse){
console.log('GOOGLE RESPONSE:', addEventError, addEventResponse);
if(!addEventError)
return response.send(200, addEventResponse);
return response.send(400, addEventError);
});
};
addGoogleEvent(req.body.accToken);
}