Google Calendar API v3:特定一周的事件 [英] Google Calendar API v3 : events from a particular week

查看:89
本文介绍了Google Calendar API v3:特定一周的事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在从Google Calendar API v3(使用Javascript)获取事件.

我一直无法访问API:

I was stuck on getting access to the API : Google Calendar API V3 and Ajax : No 'Access-Control-Allow-Origin' header

现在,我有点困惑:我试图从几天(2012-07-31到2012-08-04,GMT + 1)中获取事件列表,所以这是我尝试过的事情:

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 :

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

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

有什么想法吗?

推荐答案

您需要将'singleEvents'设置为true,我相信它会返回重复发生的事件的各个实例,而不是事件组.

You need to set 'singleEvents' to true which I believe returns individual instances of reoccurring events instead of the event group.

          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]);
               };


              });
            });

这篇关于Google Calendar API v3:特定一周的事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆