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.
Viewing both the source and target calendars at the same time can create the appearance of duplicates. Syncing between primary and shared calendars on the same account will create what seems to be duplicate events.
Color bars only show up with all day checked, and no notifications. Timed events get the dot and notifications.
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!
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With