Custom Callback Functions for Google Reader

Long-term readers of this blog will know how much I love Google Reader's sharing settings, which allow you to embed a list of headlines into a website.

The headlines are drawn from any one folder in your Google Reader account, so you can collate multiple RSS feeds into a single news feed that updates in near-real time.

I've used the functionality in both professional and personal applications - in my former agency role, it meant press releases on a particular subject could be viewed on a publicly accessible page, which made it much faster and easier to find things to write about for difficult client briefs, while I now use the same approach to embed headlines into a number of my different websites and blogs.

The particularly good thing about using Google Reader to embed RSS feeds into a web page is the 'callback' function.

This is the piece of Javascript that decides how your headlines will look once they are displayed on the page, and by default, it shows a fairly basic table with coloured headlines, a border, a title and a link to Google Reader's 'public page' for that folder of feeds.

However, it does not have to look like that...

Customising Google Reader's Callback Function

There's not a great deal of documentation out there about this, but you can alter the embed code so that, instead of using the default callback function, Google Reader uses your own piece of Javascript code, which you can then place in the header of any one page, or in the template of your blog.

Typically, you place an empty 'div' at the position on your page where you want your headlines to load, and give it a unique id.

Your Javascript then pulls the different elements - titles, summaries and timestamps - from Google Reader's RSS feed, formats them with any appropriate CSS, and pastes the resultant HTML code into the div.

It requires Javascript to be activated in the visitor's browser, in order to work, but so do most real-time page elements.

Let Me Do It For You

I've added Google Reader 'clips' to a large number of websites and blogs now, and I know my way around the callback function.

There are some limitations - you can't use it to add the full text of an item, and I'd generally dissuade you from using the summary text option too, as it's often left blank for some items or entire feeds.

However, it is quite reliable and straightforward to add headlines, links and timestamps to a page in a format that matches the rest of your template.

If you would like me to write a callback function to achieve this for you, get in touch and I will quote you a price.

In exchange, you can expect a callback function that delivers the RSS items you want with the visual style you need, and instructions on how to embed it into your page or site template.

To be clear, I have no direct affiliation with Google Reader and cannot vouch for any future service changes they might introduce - but I will do my best to provide you with code that will work at least until Google introduce any major change to the sharing functionality of Google Reader.

For more information, drop me an email or a tweet and we can talk about what you need, and how you'd like it to look.

No comments:

Post a Comment