HOWTO Delete Non-primary Google Calendar Event?
When you created google calendar event, you will get google event id. something like below :
http://www.google.com/calendar/feeds/default/private/full/yyyyy
After you created non-primary google calendar event, you will get event id similar with following :
http://www.google.com/calendar/feeds/liho.tw_xxxxx%40group.calendar.google.com/
private/full/yyyyy
Following is part of Calendar.php which only supports the google default event :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | function deleteEventById ($client, $eventId) { $event = getEvent($client, $eventId); $event->delete(); } function getEvent($client, $eventId) { $gdataCal = new Zend_Gdata_Calendar($client); $query = $gdataCal->newEventQuery(); $query->setUser('default'); $query->setVisibility('private'); $query->setProjection('full'); $query->setEvent($eventId); try { $eventEntry = $gdataCal->getCalendarEventEntry($query); return $eventEntry; } catch (Zend_Gdata_App_Exception $e) { var_dump($e); return null; } } |
You need to un-commet the following :
$query->setUser(‘default’);
And add your calendar id to similar below :
$query->setUser(‘liho.tw_xxxxx%40group.calendar.google.com’);
After you modified, you are able to delete non-primary google calendar event. However, above example is not smart enough. You should rewrite the getEvent function to add non-primary google calendar id. like below :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | function deleteEventById ($client, $eventId, $calendarid = "default") { $event = getEvent($client, $eventId, $calendarid); $event->delete(); } function getEvent($client, $eventId, $calendarid) { $gdataCal = new Zend_Gdata_Calendar($client); $query = $gdataCal->newEventQuery(); $query->setUser($calendarid); $query->setVisibility('private'); $query->setProjection('full'); $query->setEvent($eventId); try { $eventEntry = $gdataCal->getCalendarEventEntry($query); return $eventEntry; } catch (Zend_Gdata_App_Exception $e) { var_dump($e); return null; } } |