简体   繁体   English

Google Calendar API v3:特定星期的事件

[英]Google Calendar API v3 : events from a particular week

I'm currently getting events from Google Calendar API v3 (using Javascript). 我目前正在从Google Calendar API v3(使用Javascript)获取事件。

I was stuck on getting access to the API : Google Calendar API V3 and Ajax : No 'Access-Control-Allow-Origin' header 我一直无法访问API: Google Calendar API V3和Ajax:没有“ Access-Control-Allow-Origin”标头

And now, I'm a bit confused: I'm trying to get event list from few days (2012-07-31 to 2012-08-04, GMT+1), so here's what I tried : 现在,我有点困惑:我试图从几天(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]);
                   };


                  });
                });

But this request returns events with datetimes that doesn't seem to fit with what I requested: 2012-04-14T11:00:00+02:00, 2011-09-11 但是此请求返回的日期时间似乎与我要求的事件不匹配的事件:2012-04-14T11:00:00 + 02:00,2011-09-11

Any ideas ? 有任何想法吗 ?

You need to set 'singleEvents' to true which I believe returns individual instances of reoccurring events instead of the event group. 您需要将'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]);
               };


              });
            });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM