Home » Php » php – Google calendar API new recurring event with exceptions

php – Google calendar API new recurring event with exceptions

Posted by: admin February 25, 2020 Leave a comment

Questions:

I’d like to create an recurring event with few exceptions. I use official PHP API Library. Here is my code:

        new Google_Service_Calendar_Event(array(
            'id' => self::generateGoogleId($this->getId()),
            'summary' => $summary,
            'location' => null,
            'description' => $description,
            'start' => GoogleCalendarApiHelper::carbonToGoogleDateArray($this->getDateStart()),
            'end' => GoogleCalendarApiHelper::carbonToGoogleDateArray($this->getDateEnd()),
            'recurrence' => 'RRULE:FREQ=DAILY;INTERVAL=1;COUNT=20',
            'attendees' => array_map($funcAttendee, $this->attendees ?? []),
            'reminders' => array(
                'useDefault' => true,
//                'overrides' => array(
//                    array('method' => 'email', 'minutes' => 24 * 60),
//                    array('method' => 'popup', 'minutes' => 10),
//                ),
            ),
        ));

I need to create few exception (for example move 2nd and 3th event from origin start time 6am to new start time 11am). How can I do it in my code? I’d like to do it in one request. There is only one way in doc how to create expceptions – recurrence[] - EXRULE or EXDATE. But EXRULE or EXDATE are for canceling of events I need move (reschedule these events) not cancel these events.

Thank you.

How to&Answers: