views:

681

answers:

2

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.

+1  A: 

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

Josh Lindsey
+4  A: 

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!

Oli