5
votes

I'm trying to show a list of the next 20 days' events from a Google calendar account. Infuriatingly recurring events aren't being shown (I assume because their start times are old)... So. Any ideas?

require_once dirname(__FILE__).'/../../../Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_HttpClient');
Zend_Loader::loadClass('Zend_Gdata_Calendar');

$service = new Zend_Gdata_Calendar();

$query = $service->newEventQuery();
$query->setUser('REMOVED');
$query->setVisibility('public');
$query->setProjection('full');
$query->setOrderby('starttime');
$query->setSortOrder('ascending');
$query->setFutureevents('true');
$query->setMaxResults(20); 

try { $eventFeed = $service->getCalendarEventFeed($query); }
catch (Zend_Gdata_App_Exception $e) { return; }

I'm willing to accept any alternative methods that get all my public events in ascending order. I've tried RSS but the dates appear to be the time they were added to the calendar.

2
Seconded. I'm yet to find a single calendar feed (iCal, google calendar, xml) library that does this well.xkcd150

2 Answers

6
votes

The projection is something I've played with before. It doesn't help (unless I want to parse and explode recurring events manually). But that link was golden.

$query->setParam('singleevents','true');

From their docs:

singleevents

Indicates whether recurring events should be expanded or represented as a single event.

Valid values are true (expand recurring events) or false (leave recurring events represented as single events). Default is false.

In my opinion, false is a stupid default but hey-ho. It appears to work now!

1
votes

Changing this:

$query->setProjection('full');

To this:

$query->setProjection('composite');

Will give you all sorts of extra data, including recurring events. This is per the Google Calendar API reference: http://code.google.com/apis/calendar/docs/2.0/reference.html