获取 API Google 日历事件的重复发生 [英] Getting Recurrence of API Google Calendar Events

查看:41
本文介绍了获取 API Google 日历事件的重复发生的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早上好,

我正在创建一个与 Google 日历同步的日历,但我无法重现 Google 日历的活动.我认为事件的重复"字段是受保护的字段.但我不知道如何获取已保存事件的字段.

I'm creating a Calendar that syncronizes with Google Calendar, but I can´t get the recurrence of the Events of Google Calendar. I think the field "recurrence" of the events is a protected field. But I don't know how to get the field of a saved Event.

代码:

$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;
}

如果我尝试打印事件的内容,它会向我显示一个空字段重复,并且我已经证明它是重复的.

And If I try to print the content of the events, it shows me an empty field recurrence, and I have proved that it's recurrent.

谢谢!

推荐答案

如果当前事件不是拥有重复规则的原始事件,则它不包含它自己的重复"字段副本.相反,将在recurringEventId"字段中引用原始事件.

If the current event is not the original event which owns the recurrence rules, it doesn't contain its own copy of the 'recurrence' field. Instead there will be a reference to the original event in the 'recurringEventId' field.

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

If you then fetch that referenced event, you will find the recurrence rules.

例如(使用 Python API)...

E.g. (using the 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']

这篇关于获取 API Google 日历事件的重复发生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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