[英]Google Calendar API err not found
I am using google calendar to get my calendar events.Google Calendar API tutorial is here . 我正在使用Google Calendar获取我的日历事件。GoogleCalendar API教程在此处 。
All works well I can get my event by setting the calendarId:'primary'
. 一切正常,我可以通过设置calendarId:'primary'
来获取事件。
There are also some other calendars besides 'primary' in my calendar, like holidays. 我的日历中除了“主”日历外还有其他日历,例如假期。 Then I think I should change the calendarId
to others to get the events, but I got error: 然后我认为我应该将calendarId
更改为其他人以获取事件,但是我得到了错误:
Error: Not Found
The code is like below: zh_cn.china#holiday@group.v.calendar.google.com
this calendarId
doesn't work, 代码如下: zh_cn.china#holiday@group.v.calendar.google.com
此calendarId
无效,
calendar.events.list({
calendarId: 'primary',
//calendarId: 'zh_cn.china#holiday@group.v.calendar.google.com',
timeMin: (new Date()).toISOString(),
maxResults: 50,
singleEvents: true,
orderBy: 'startTime',
}, (err, {data}) => {
if (err) return console.log('The API returned an error: ' + err);
const events = data.items;
if (events.length) {
console.log('Upcoming 10 events:');
events.map((event, i) => {
const start = event.start.dateTime || event.start.date;
console.log(`${start} - ${event.summary}`);
});
} else {
console.log('No upcoming events found.');
}
});
I also tried to get all the calendarIds from my account: 我还尝试从我的帐户中获取所有calendarIds:
calendar.calendarList.list({
maxResults: 100
},function (err, result) {
console.log(result.data.items);
})
The result is like: 结果是这样的:
[{ kind: 'calendar#calendarListEntry',
etag: '"1530087829067000"',
id: 'zh_cn.china#holiday@group.v.calendar.google.com',
summary: '中国节假日',
timeZone: 'Asia/Shanghai',
colorId: '12',
backgroundColor: '#fad165',
foregroundColor: '#000000',
accessRole: 'reader',
defaultReminders: [],
conferenceProperties: { allowedConferenceSolutionTypes: [Array] } ]
Looks like the calendarId is correct. 看起来calendarId是正确的。
Any help? 有什么帮助吗? Thanks! 谢谢!
我发现的方式是:
calendarId: encodeURIComponent(id)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.