重新启动API Google日历活动

时间:2015-06-08 08:03:17

标签: api google-calendar-api google-calendar-recurring-events

早上好,

我正在创建一个与Google日历同步的日历,但我无法重复Google日历的事件。我认为事件的“重现”是一个受保护的领域。但我不知道如何获得已保存事件的领域。

编辑:代码:

$params = array(
                'orderBy' => 'startTime',
                'singleEvents' => 'true',
                'timeMin' => date(DateTime::ATOM),
        );
$listarEventos = $service->events->listEvents($calendar_id, $params);
foreach ($listarEventos['items'] as $i){
     echo $i->recurrence;
}

如果我尝试打印事件的内容,它会显示一个空的字段重复,我已经证明它是经常发生的。

谢谢!

2 个答案:

答案 0 :(得分:0)

Events.list返回事件资源列表。

"kind": "calendar#event",
   "etag": "\"9722590000\"",
   "id": "3nmhbd0465ts1enliigj4",
   "status": "confirmed",
   "htmlLink": "https://www.google.com/calendar/event?eid=285781",
   "created": "2015-04-13T07:24:21.000Z",
   "updated": "2015-04-13T07:24:21.509Z",
   "summary": "My event",
   "location": " ",
   "creator": {
    "email": "XXX@gmail.com",
    "displayName": "XXX",
    "self": true
   },
   "organizer": {
    "email": "XXX@gmail.com",
    "displayName": "XXX",
    "self": true
   },
   "start": {
    "dateTime": "2015-04-21T19:00:00+02:00",
    "timeZone": "Europe/Copenhagen"
   },
   "end": {
    "dateTime": "2015-04-21T21:00:00+02:00",
    "timeZone": "Europe/Copenhagen"
   },
   "recurrence": [
    "RRULE:FREQ=WEEKLY;COUNT=24;BYDAY=TU"
   ],
   "iCalUID": "XXX@google.com",
   "sequence": 0,
   "reminders": {
    "useDefault": false,
    "overrides": [
     {
      "method": "popup",
      "minutes": 45
     }
    ]
   }

如果事件有一个重复设置,你可以在那里找到它。

  

"复发":[           " RRULE:FREQ = WEEKLY; COUNT = 24; BYDAY = TU"          ]

我无法看到您的代码如何访问它,但如果您在event.list的底部进行测试,您会注意到如果您有权访问日历,则应该可以访问重复字段。

答案 1 :(得分:0)

如果当前事件不是拥有重复规则的原始事件,则它不包含其自身的“重复发生”副本。领域。相反,将会在“recurringEventId”中引用原始事件。字段。

如果您随后获取引用的事件,您将找到重复规则。

E.g。 (使用Python API)......

...
events = service.events().list(calendarId=calId,
                               singleEvents=True,  # expand recurrence events
                               q=searchString
                              ).execute()
for e in events['items']:
    if 'recurringEventId' in e:
        root_ev = service.events().get(CalendarId=calId,
                                       eventId = e['recurringEventId']
                                      ).execute()
        # Copy the recurrence rules from the root event into our own:
        e['recurrence'] = root_ev['recurrence']