想要创建每年重复的Google Clanedar活动

时间:2016-01-29 04:45:14

标签: php api google-calendar-api google-api-php-client

我成功地设法通过php api客户端将事件添加到谷歌日历,但我想要的是每年重复该事件,例如公司anniversay等,我也没有在谷歌文档中找到,那么在创建重复事件时应该添加什么

1 个答案:

答案 0 :(得分:0)

There is documentation for recurring event

$event = new Google_Service_Calendar_Event();
$event->setSummary('Appointment');
$event->setLocation('Somewhere');
$start = new Google_Service_Calendar_EventDateTime();
$start->setDateTime('2011-06-03T10:00:00.000-07:00');
$start->setTimeZone('America/Los_Angeles');
$event->setStart($start);
$end = new Google_Service_Calendar_EventDateTime();
$end->setDateTime('2011-06-03T10:25:00.000-07:00');
$end->setTimeZone('America/Los_Angeles');
$event->setEnd($end);
$event->setRecurrence(array('RRULE:FREQ=YEARLY;UNTIL=20110701T170000Z'));
$attendee1 = new Google_Service_Calendar_EventAttendee();
$attendee1->setEmail('attendeeEmail');
// ...
$attendees = array($attendee1,
                   // ...
                   );
$event->attendees = $attendees;
$recurringEvent = $service->events->insert('primary', $event);

echo $recurringEvent->getId();