Here is an embedded calendar with four calendars. There is a public calendar, a public calendar sharing only free busy information, a private calendar and a shared calendar. You can only see the private calendar if you are logged in as calendar.maven@gmail.com, you can only see the shared calendar if I have invited you to see it and you are logged in with that address and anyone can see the public calendar and the public free busy information, but on the Free Busy calendar you will only see times when calendar maven is busy.

I’m writing more Javascript and AJAX these days, so not coincidentally, I am also spending more time:

Inspecting the DOM of pages.

Checking the validity of CSS and XHTML.

Checking for Javascript syntax errors.

Breakpointing Javascript.

Viewing the rendered source of pages.

On top of that, there are a number of other tasks that I do frequently as I develop for the web:

Measuring page load time.

Snoop on, and alter, http requests and responses.

Clear and/or disable the cache.

Clear all or selected cookies.

Spoof a site as a different browser.

For all of these tasks, Firefox is the browser for me. There are useful tools for Safari, Internet Explorer and, I assume, Google Chrome, but Firefox with the Firebug, DOM Inspector, Live HTTP Headers, Tamper Data, User Agent Switcher, View Source Chart, Web Developer and YSlow plugins is the set of tools that I am the most comfortable using for these tasks.

The problem usually is that I don’t really want all of these extensions around when I am focused on reading or casually surfing the web. This morning, it occurred to me that I could use the techniques that I used in creating Firefoxen to create a special purpose web application development browser.

A few minutes later:

Here is what I did.

# Make a copy of Firefoxcp-pr/Applications/Firefox3.app /Applications/WebFox.app
# Create a new profile, I called mine WebFox
WebFox.app/Contents/MacOS/firefox-bin -P# I used my existing profile as a baseline, you might not want tocd ~/Library/Application\ Support/Firefox/Profiles/rm-fr 40of1s4x.WebFox/cp-pr u5qu37ob.default 40of1s4x.WebFox
# Change the Bundle Name to "WebFox"
open /Applications/WebFox.app/Contents/Info.plist
# Change launch-ff command to (no quotes) # "/Applications/WebFox.app/Contents/MacOS/firefox-bin -P WebFox"vi/Applications/WebFox.app/Contents/MacOS/launch-ff
# CFBundleName is WebFox for display in the tool bar# You probably need the Developer Tools installed for this to work
open /Applications/WebFox.app/Contents/Resources/en.lproj/InfoPlist.strings

Before writing, I assumed that I would need to refer any reader to the introductory post of this series on adding events to secondary calendars. Depending on your skill level and experience that may still be true, and it definitely is true if you want to understand what you are doing, but if you just want to get it done, you can probably muddle through with the following instructions.

Here’s the really short story: when you call the insertEvent method, you pass the event that you are creating and optionally, the edit url of the calendar where you want the event to appear. So, to create an event on a secondary calendar, just pass the edit link of the calendar. (You can get the edit link of a calendar in python by calling GetEditLink().href on it.)

For the longer story, I’ll assume that you have installed Python, ElementTree and the Google Data Python Library, following Google’s instructions.

Run through the tests and the sample code. When I ran the calendarExample.py it failed with this stack trace:

Since all I wanted to do was to make this sample code run for the single case of adding an event to a secondary calendar, I commented out line 99, but the code should be checking that there is an attendee status before writing its value. After that change the sample code ran fine for me.

To insert a single event in a secondary calendar, I copied calendarExample.py to secondaryCalendarInsert.py. Then I commented out everything in the Run method except this line:

This instructs the InsertEvent method to create the event in my secondary calendar by POSTing to the url of my “Secondary Calendar” (id g5b79g3f2bi5hc1it41seuu41c@group.calendar.google.com) instead of my primary calendar (id default). I found the calendar ID on the calendar settings page of the calendar, but as I said above, if you have accessed a calendar programatically, you can just call GetEditLink().href on it to get the proper link.

You can see that a “One Time Tennis with Beth” event was inserted beginning at the moment I did the insert and lasting for one hour, as described in the sample code.

[Update 2008-11-14: You can't see this if you are using Safari. In general embedded calendar's show in Safari, but there is something about this particular calendar that causes it not to display. Google does a number of separate calls and redirects to obtain the correct data for this calendar and it looks like one of the calls returns data that doesn't correspond to the mime-types. The point that I was trying to communicate with this illustration was that the event did in fact appear and that it was on the secondary calendar.]

This is a little out of my normal area here, but I received this question in my email and I figured I’d answer it here for everyone’s future reference. Maybe I’ll become the next “Ask Dave“?

On Sep 9, 2008, at 9:05 AM, nadine wrote:
Dear Ray,

I do hope you don’t mind my email you… I am desperate!!!

I work for a gentleman who in turn works for 6 different companies. Because his calendar entries need to be colour coded I have obviously set up a calendar representing each different company which shows a different colour. This works fine between he and I.

However, he would like to share his calendar with a number of colleagues. Do I firstly have to ask each of his colleagues to open a Google account and then do I send an invite to them? However, I think this invites them only to his one calendar and not to all the associated company calendars?Read the rest of this entry »

In this series of posts, I am going to attempt to provide an answer for using every language that has a client library. I discuss the “official” client libraries for Python, Php, .NET, Java and Javascript as well as the slightly less official Objective-C library and some of the attempts to create Ruby library for interacting with Google Calendar and GData. If there are other client libraries, just let me know in the comments and I’ll add instructions here, or link to them elsewhere as I have time, interest and understanding.

I start with describing how to POST XML to a calendar url. This is “The Protocol”. You should read this information about the protocol, even if you plan to use a client library. Each client library is using this protocol under the covers, so understanding what is happening will help you better use your client library. In addition, I’ll only explain some terms in this section, so you’ll need to read it to understand what I am talking about.

All information in these posts comes from the Google Developer’s Guides, the Client Library Documentation, the source code for the client library and my own exploration and testing. I’ll provide links to these resources in the text as appropriate. For simplicity’s sake, I only cover creating single-occurrence events for users that have properly authenticated using client login. These cases should be sufficient for illustrating how to add to secondary calendars, but 1) I’m not aware of any differences in creating single-occurrence versus quickadd or recurrent events on secondary calendars in any of the client libraries and 2) I haven’t used AuthSub.

I have personally tested all of the code that I present here, unless otherwise noted. That means that I was able to create an event on a calendar using that code. In all cases, I am adding events to my Secondary Calendar which is public, so have a look. I’ll be trying to add an event that occurs at the time when the relevant article is posted.

Here is a table of contents of the language-specific treatments. I’ll update the links as I complete the sections.

Here for reference is a complete listing of the rel and type attributes I have observed for link elements in Google Calendar feeds. These are a superset of the attributes contained in link elements found in event feeds. Google Calendar feeds do not use all available combinations of permitted Atom link elements. A complete list of Atom link relations is here. Atom requires that each element have a maximum of one link of each relation and type. Types are specified here for Atom elements. None of the observed relations from outside the Atom namespace have types.

Notes

Alternate links point to an alternate representation of the same resource. There are three types represented in Google Calendar feeds; the type specifies that nature of the alternate representation. The application/atom+xml type alternate links are all contained inside elements and point to the individual entry. The text/html type links are to html representations of the calendar or event. The text/calendar are links to ics format calendar files.

The edit links are used to update or delete calendars or events. The post links are used to create calendars or events. The edit links are defined in the Atom Publishing Protocol. Post links are Google’s own invention.

Batch links identify the uri for posting batch request. I have no experience with batch requests, but according to the documentation insert, update, delete, or query operations are permitted.

Feed links in all observed cases are exactly the same as the id of the feed. The self links are related to the feed links and id, but also contain the (possibly implicit) url parameters that were used to retrieve the feed.

AccessControlList links identify the location of the access control list (acl) for the feed. ControlledObject links identify the feed that the acl pertains to.

I’ve read this paragraph many times, but somehow the full meaning just became apparent to me.

Just like in the previous example, Calendar may return an HTTP 302 redirect; if so, then the redirect URL has a new parameter, gsessionid, appended to it. If you received the redirect, then send the same POST request again, with the same Authorization header and the same content, but with the gsessionid parameter appended. The response may also include a S cookie, which you should store and send this cookie with future requests as appropriate. Please see the knowledge base for more information on handling sessions with the Calendar data API. Please note: if a session ID indicated in a cookie header conflictswith the session ID passed as a gsessionid URL parameter, you will get caught in a redirect loop.

The introductory clause obscures important information. Having read the previous example, I thought that there wasn’t much to be gained by reading this paragraph in detail. Just do the same thing as before, “So after you’ve sent the GET request, you have to read the HTTP headers of the response to find the URL with the session ID appended; then you need to send another GET request with that new URL.”

Really, I didn’t think too much. The gsessionid is a persistent session id. You can send it with any future request and if you do, and the session id matches the auth token your request will be accepted without redirect. Moreover you can grab the S cookie and stick it in your headers and not need to worry about it.This is documented here.

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.

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 .

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.