Posts Tagged ‘GData’
Link Elements in GCalendar Event Feeds
Posted on
April 27th, 2008 by
yesteray
No Comments
A question from the for the Google Calendar Data API Developer Forum.
Hi all,
for (CalendarEventEntry event : calEventList) { for (Link link : event.getLinks()) { System.out.println(link.getHref()); }above code fragment prints three types of links, what these are meant for?
What these links signify in the feed.
–
Regards,
Vijay
This is a question that I had been meaning to address, but I was planning to get to it after I addressed all the different urls that are used in the GCalendar API. Actually this question is easier and more straight-forward to answer, so it makes sense to answer this first. I’ll defer the larger questions of GCalendar event feeds and generic Atom feeds for a later post.
Here’s a complete entry feed (as formated with tidy -xml -indent):
<?xml version='1.0' encoding='utf-8'?> <entry xmlns='http://www.w3.org/2005/Atom' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:gCal='http://schemas.google.com/gCal/2005' xmlns:gd='http://schemas.google.com/g/2005'> <id> http://www.google.com/calendar/feeds/td3s32e6k1ib7pkgibi7v6jktg%40group.calendar.google.com/private/full/g0pdsjl18em9tcdau6baqgatkk</id> <published>2008-04-21T22:36:07.000Z</published> <updated>2008-04-21T22:36:07.000Z</updated> <category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event' /> <title type='text'>Tennis with Beth</title> <content type='text'>Meet for a quick lesson.</content> <link rel='alternate' type='text/html' href='http://www.google.com/calendar/event?eid=ZzBwZHNqbDE4ZW05dGNkYXU2YmFxZ2F0a2sgdGQzczMyZTZrMWliN3BrZ2liaTd2NmprdGdAZw' title='alternate' /> <link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/td3s32e6k1ib7pkgibi7v6jktg%40group.calendar.google.com/private/full/g0pdsjl18em9tcdau6baqgatkk' /> <link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/td3s32e6k1ib7pkgibi7v6jktg%40group.calendar.google.com/private/full/g0pdsjl18em9tcdau6baqgatkk/63344500567' /> <author> <name>Ray Baxter</name> <email>me@gmail.com</email> </author> <gd:comments> <gd:feedLink href='http://www.google.com/calendar/feeds/td3s32e6k1ib7pkgibi7v6jktg%40group.calendar.google.com/private/full/g0pdsjl18em9tcdau6baqgatkk/comments' /> </gd:comments> <gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed' /> <gd:visibility value='http://schemas.google.com/g/2005#event.default' /> <gd:transparency value='http://schemas.google.com/g/2005#event.opaque' /> <gCal:uid value='g0pdsjl18em9tcdau6baqgatkk@google.com' /> <gCal:sequence value='0' /> <gd:when startTime='2008-04-17T08:00:00.000-07:00' endTime='2008-04-17T10:00:00.000-07:00' /> <gd:who rel='http://schemas.google.com/g/2005#event.organizer' valueString='' email='td3s32e6k1ib7pkgibi7v6jktg@group.calendar.google.com' /> <gd:where valueString='Rolling Lawn Courts' /> </entry>
Coming to Vijay’s question, there are three <link> elements in this feed. They are:
<link rel='alternate' type='text/html' href='http://www.google.com/calendar/event?eid=ZzBwZHNqbDE4ZW05dGNkYXU2YmFxZ2F0a2sgdGQzczMyZTZrMWliN3BrZ2liaTd2NmprdGdAZw' title='alternate' /> <link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/td3s32e6k1ib7pkgibi7v6jktg%40group.calendar.google.com/private/full/g0pdsjl18em9tcdau6baqgatkk' /> <link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/td3s32e6k1ib7pkgibi7v6jktg%40group.calendar.google.com/private/full/g0pdsjl18em9tcdau6baqgatkk/63344500567' />
The links are named for their relations, i.e. the values of their rel attributes.
The first link is the alternate link, so called because it is an alternative version of the content of this event. In this case the alternate version in html format as you can see by the type='text/html' attribute. Because this calendar is public, you can click on that link and see the event in your browser. Try it.
The second link is a self link. That is the the xml feed for this event, and can repull the event from this feed (in the event that Google’s servers are working, which they don’t appear to be currently.) Notice that the http attribute of the self link is exactly the same URL as the <id>.
<id> http://www.google.com/calendar/feeds/td3s32e6k1ib7pkgibi7v6jktg%40group.calendar.google.com/private/full/g0pdsjl18em9tcdau6baqgatkk</id> <link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/td3s32e6k1ib7pkgibi7v6jktg%40group.calendar.google.com/private/full/g0pdsjl18em9tcdau6baqgatkk' />
The self link may not have been the location from you pulled the event. You might have pulled an entire calendar of events (which would have it’s own, distinct, self link) or you might have made a query for events matching some pattern and retrieved a number of events for that feed (which would ought have it’s own self link, but I haven’t verified).
Finally there is the edit link. This is the URL that you use to make changes to the event. Sending a DELETE request to this URL will delete the event. Sending a PUT request will replace event’s data with the data that you send.
For reference, the self and alternate link relations are specified as part of the Atom Syndication Format (RFC4287) and the edit relation is specified as part of the Atom Publication Protocol (RFC5023). A convenient table of all the Atom link relations is here. That table will come in handy as we examine the other link relations in GCalendar feeds.
Any other questions? Leave them in the comments and I’ll get to them as I can.
Search:
Recent Posts
- Running Multiple Versions of Firefox
- Adding Events to Secondary Google Calendars in Python
- Q & A - Sharing Calendars
- Adding Events to Secondary Google Calendars
- Link Elements in GCalendar Calendar Feeds
Categories
Relevant Links
AtomPub
- Getting to know the Atom Publishing Protocol, Part 1: Create and edit Web resources with the Atom Publishing Protocol
- Getting to know the Atom Publishing Protocol, Part 2: Put the Atom Publishing Protocol (APP) to work
Date and Time
GCalendar
- Articles and Tutorials
- Bugs and Enhancements
- Calendar API FAQ
- Calendar Feeds
- Developer’s Guide
- Google Calendar Data API Group
- Reference Guide
GData
- Authentication
- Batch Processing
- Client Libraries
- Common Elements
- Issues
- libgcal
- Overview
- Protocol Basics
- Protocol Reference
- Reference
- Samples
- Zend Documentation
iCalendar Tools
Online Calendars
- 30 Boxes
- CalendarHub - Web Calendars
- Google Calendar
- LuckyCal.com
- Online calendar publishing: Google Calendar
- Online calendar publishing: iCal
- Online calendar publishing: Outlook
- RSSCalendar
- The Human Calendar
- Yahoo! Calendar
Tags: