I'm struggling to update an event on google calendar. I'm using google-api-php-client. I want to update description of one event at a time using following code.
my@gmail.com is my primary account.
$currEvent = $service->events->get("my@gmail.com", $event_id);
$currEvent->setDescription("Test DESCRIPTION");
$service->events->update("my@gmail.com", $currEvent->getId(), $currEvent);
I'm using above code to update.
Get event is returning proper result but update event is throwing following error:
Fatal error: Uncaught exception 'Google_Service_Exception' with message 'Error calling PUT https://www.googleapis.com/calendar/v3/calendars/my%40gmail.com/events/d6ao1oaiaa7s0aif229btheiv4?key=AIzaSyBQJ2hQzpYn8UIL97VKkg3tBFTq9nFAQUE: (403) Forbidden' in /google-api-php-client/src/Google/Http/REST.php:76 Stack trace: #0 /google-api-php-client/src/Google/Http/REST.php(41): Google_Http_REST::decodeHttpResponse(Object(Google_Http_Request)) #1 /google-api-php-client/src/Google/Client.php(548): Google_Http_REST::execute(Object(Google_Client), Object(Google_Http_Request)) #2 /google-api-php-client/src/Google/Service/Resource.php(190): Google_Client->execute(Object(Google_Http_Request)) #3 / in /google-api-php-client/src/Google/Http/REST.php on line 76
I've tried adding an event to google calendar using following code and it's working:
$event = new Google_Service_Calendar_Event();
$event->setSummary('Appointment');
$event->setLocation('test location');
$start = new Google_Service_Calendar_EventDateTime();
$start->setDateTime('2014-12-12T10:00:00.000-07:00');
$event->setStart($start);
$end = new Google_Service_Calendar_EventDateTime();
$end->setDateTime('2014-12-12T10:25:00.000-07:00');
$event->setEnd($end);
$attendee1 = new Google_Service_Calendar_EventAttendee();
$attendee1->setEmail('abc@test.com');
// ...
$attendees = array($attendee1);
$event->attendees = $attendees;
$createdEvent = $service->events->insert('primary', $event);
echo $createdEvent->getId();
Any help is most appreciated.
Cheers!!!