Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google calendar - Showing recurring events like normal events

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.

like image 639
Oli Avatar asked Aug 17 '09 14:08

Oli


People also ask

Why are all my Google Calendar events duplicating?

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.

Why are some Google Calendar events dots?

Color bars only show up with all day checked, and no notifications. Timed events get the dot and notifications.


2 Answers

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!

like image 196
Oli Avatar answered Sep 21 '22 07:09

Oli


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

like image 26
Josh Lindsey Avatar answered Sep 22 '22 07:09

Josh Lindsey