5

I had a long detailed question about how to get a specific calendar's event feed, but figured (I think) a solution out before I posted. However, even with the solution I'm left wondering what I'm missing about this process. To get a single calendar's event feed (or to search that feed) I do the following:

  • Authenticate (obviously)
  • Get a list of Calendars: getCalendarListFeed();
  • Get the id property from one of the 'calendar' objects
  • Change: .../calendar/feeds/default/XXX%40YYY
  • To: .../calendar/feeds/XXX%40YYY/private/full
  • Pass that to getCalendarEventFeed() to query for that calendar.

Why do I have to manipulate the ID? It seems like the documentation for Zend_Gdata is spread over both Google's and Zend's sites. I haven't located a good reference on available properties from getCalendarListFeed(), so maybe I should grab something other than the ID?

It seems like there has to be more straightforward way - what am I missing here?

Tim Lytle
  • 17,549
  • 10
  • 60
  • 91

2 Answers2

3

You don't have to manipulate the ID.

If you look at the protocol guide, there's a <link rel="alternate" .../> element which contains the URL you want.

In the PHP client, you can retrieve this link by calling:

// $entry is an instance of Zend_Gdata_Calendar_ListEntry
$link = $entry->getAlternateLink()->getHref();

Also, the documentation you're looking for is here: http://framework.zend.com/apidoc/1.9/Zend_Gdata/Calendar/Zend_Gdata_Calendar_ListEntry.html

Trevor Johns
  • 15,682
  • 3
  • 55
  • 54
2

I was looking for an answer to this same question and eventually came up with the following:

$service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
$Client = Zend_Gdata_ClientLogin::getHttpClient('googleaccount','googlepass',$service);
$Service = new Zend_Gdata_Calendar($Client);

$Query = $Service->newEventQuery();
$Query->setUser('calendarid'); # As you know, you can obtain this with getCalendarListFeed()
$Query->setVisibility('public');
$Query->setProjection('full');
$Query->setOrderby('starttime');
$Query->setFutureevents('true');

The part that threw me off at first was that the "user" portion of the call is actually the calendar ID. Then you can do something like:

$events = $Service->getCalendarEventFeed($Query);
foreach ($events as $Event)
{
   // work with Event object here...
}

(The above should really be enclosed in a try/catch, but I'm too lazy to do that here.)

bogeymin
  • 685
  • 1
  • 9
  • 27
  • The calendarid is the email address of the calendar in the private settings. setVisibility->('private'); # for private calendar (not public) – Scott Fleming Sep 15 '13 at 11:05