我目前正在从 Google Calendar API v3(使用 Javascript)获取事件。
我被困在访问 API 上:Google Calendar API V3 and Ajax : No 'Access-Control-Allow-Origin' header
现在,我有点困惑:我正在尝试获取几天(2012-07-31 到 2012-08-04,GMT+1)的事件列表,所以这就是我尝试过的:
gapi.client.load('calendar', 'v3').then(function(data) {
var request = gapi.client.calendar.events.list({
'calendarId': '[cal id]',
"timeMin": "2012-07-31T00:00:00+01:00",
"timeMax": "2012-08-05T00:00:00+01:00"
});
request.execute(function(resp) {
for (var i = 0; i < resp.items.length; i++) {
console.log(resp.items[i]);
};
});
});
但是此请求返回的事件的日期时间似乎与我的请求不符:2012-04-14T11:00:00+02:00, 2011-09-11
有什么想法吗?
最佳答案
您需要将“singleEvents”设置为 true,我相信这会返回重复发生事件的单个实例,而不是事件组。
gapi.client.load('calendar', 'v3').then(function(data) {
var request = gapi.client.calendar.events.list({
'calendarId': '[cal id]',
'singleEvents': true,
"timeMin": "2012-07-31T00:00:00+01:00",
"timeMax": "2012-08-05T00:00:00+01:00"
});
request.execute(function(resp) {
for (var i = 0; i < resp.items.length; i++) {
console.log(resp.items[i]);
};
});
});
关于javascript - 谷歌日历 API v3 : events from a particular week,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27153472/