what best way add possibly 10,000 20,000 events @ once google calendar php?
if try adding them separately "limit exceeded" error far before daily max.
i've been looking @ importing ical/ics files can't seem find function besides calendar subscriptions. calendar subscriptions great need have "real-time" updates in calendars when event gets changed , it's unclear when calendar subscriptions updated take as day initial change in ics file.
need use batch requests. batch request consists of multiple api calls combined 1 http request. batch processing known feature request , actively worked on. read following article it: https://developers.google.com/google-apps/calendar/batch
see multipleinsert function example:
class my_google_calendar { ... /** add single event student */ function addevent($lesson, $instructor, $return_request = false, $enable_attendees = false) { $calendar = $this->getgooglecalendar(); // calendar service variable $lesson_from = date(date_rfc3339, $lesson->from); $lesson_to = date(date_rfc3339, $lesson->from + $lesson->duration); $event = new google_service_calendar_event(); $event->setsummary('lesson student: '$lesson->student_full_name); $start = new google_service_calendar_eventdatetime(); $start->setdatetime($lesson_from); $start->settimezone($this->getgooglecalendartimezone()); $event->setstart($start); $end = new google_service_calendar_eventdatetime(); $end->setdatetime($lesson_to); $end->settimezone($this->getgooglecalendartimezone()); $event->setend($end); $event->setcolorid(4); $description = "..."; $event->setdescription($description); if (isset($student->email) && $enable_attendees) { $attendee1 = new google_service_calendar_eventattendee(); $attendee1->setresponsestatus('needsaction'); $attendee1->setemail($student->email); $attendees = array($attendee1); $event->setattendees($attendees); } $createdevent = $this->calendar->events->insert($this->calendar_id, $event, array('fields' => 'id')); return $return_request ? $createdevent : $createdevent->getid(); } /** push group of events calendar */ function multipleinsert ($lessons, $instructor) { $this->use_batch = true; $this->client->setusebatch($this->use_batch); $batch = new google_http_batch($this->client); foreach($lessons $time => $lesson) { $lesson = array_shift($group['lessons']); $req = $this->addevent($lesson, $instructor, true); $batch->add($req, $time); } } $results = $batch->execute(); return $results; } }
Comments
Post a Comment