undefined htmlLink Google 日历插入
undefined htmlLink Google Calendar Insert
显然,当我尝试在我的 GCalendar 上插入新事件时遇到了问题。站点 return 事件已创建:未定义,我正确地建立了连接和身份验证,并且可以列出我的实际日历事件,但仍然无法插入新事件
var test = {
"summary":"TEST",
"description":"TEST",
"start":
{
"dateTime":"2017-01-01T12:00:00.000+01:00"
},
"end":
{
"dateTime":"2017-01-01T12:30:00.000+01:00"
}
};
var request = gapi.client.calendar.events.insert({
'calendarId': 'primary',
'resource': test
});
request.execute(function(test) {
appendPre('Event created: ' + test.htmlLink);
});
有什么解决办法吗?
您需要将 Events.insert 代码包含在一个函数中,该函数将在授权 (use the JS Quickstart) 完成后调用。
function loadCalendarApi() {
gapi.client.load('calendar', 'v3', insertEvent);
}
//this is the function that will be called
function insertEvent() {
var event = {
'summary': 'Google I/O 2017',
'location': '800 Howard St., San Francisco, CA 94103',
'description': 'A chance to hear more about Google\'s developer products.',
'start': {
'dateTime': '2017-01-20T09:00:00-07:00',
'timeZone': 'America/Los_Angeles'
},
.
.
request.execute(function(event) {
appendPre('Event created: ' + event.htmlLink);
console.log("Event added to Calendar");
});
}
完整的工作代码is here。使用你自己的 CLIENT_ID.
显然,当我尝试在我的 GCalendar 上插入新事件时遇到了问题。站点 return 事件已创建:未定义,我正确地建立了连接和身份验证,并且可以列出我的实际日历事件,但仍然无法插入新事件
var test = {
"summary":"TEST",
"description":"TEST",
"start":
{
"dateTime":"2017-01-01T12:00:00.000+01:00"
},
"end":
{
"dateTime":"2017-01-01T12:30:00.000+01:00"
}
};
var request = gapi.client.calendar.events.insert({
'calendarId': 'primary',
'resource': test
});
request.execute(function(test) {
appendPre('Event created: ' + test.htmlLink);
});
有什么解决办法吗?
您需要将 Events.insert 代码包含在一个函数中,该函数将在授权 (use the JS Quickstart) 完成后调用。
function loadCalendarApi() {
gapi.client.load('calendar', 'v3', insertEvent);
}
//this is the function that will be called
function insertEvent() {
var event = {
'summary': 'Google I/O 2017',
'location': '800 Howard St., San Francisco, CA 94103',
'description': 'A chance to hear more about Google\'s developer products.',
'start': {
'dateTime': '2017-01-20T09:00:00-07:00',
'timeZone': 'America/Los_Angeles'
},
.
.
request.execute(function(event) {
appendPre('Event created: ' + event.htmlLink);
console.log("Event added to Calendar");
});
}
完整的工作代码is here。使用你自己的 CLIENT_ID.