views:

472

answers:

2

Using the Zend Gdata Calendar classes, how can I add an exception to a recurring event?

$orig = $evtFeed[0]; //the original recurrence

$ex = $gc->newEventEntry(); //gc is a Zend_Gdata_Calendar object
$ex->originalEvent = $gc->newOriginalEvent($orig->getId(), $orig->getLink('self')->href, $gc->newWhen('2009-09-23T15:00:00.000Z'));
$ex->eventStatus = $gc->newEventStatus("http://schemas.google.com/g/2005#event.canceled");

$gc->insertEvent($ex);

I've tried about 20 variations of the above code but I get the following error every time:

Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 403 g:originalEvent [2009-09-23 15:00:00] does NOT correspond to an instance of the recurring event.'

+1  A: 

Well, after hours and hours of searching on the internet, I've come to the conclusion that this may be possible with the zend api, but I will never figure it out. I finally gave up and resorted to editing the recurrence and adding EXDATE rules to the iCalendar data. Thanks to a bug in the google calendar interface, exceptions created this way don't show up unless you refresh the page (the refresh link above the calendar doesn't work) so I wasted even more time.

If anyone finds a way to get this working without resorting to EXDATE please post and I'll be sure to check back periodically and mark the correct answer.

UPDATE: Ok I figured it out. I'm going to blame this one partially on me being an idiot and partially on Google's horrible naming system. Calling getId() on an EventEntry actually returns the event's EDIT URL. The OriginalEvent constructor expects only the actual ID portion of the URL so you must use substring to extract it. How nice of them to name the getId() accessor correctly.

takteek
A: 

You don't need to parse getId, just use calendarEventEntry.getIcalUID().

David Reynolds