Adding your Google Reader ‘shared items’ to your site

Posted on 28 July 2007 at 8:31 UTC, filed under PHP, disclaimer

In order to display the Google Reader ‘shared items’ on your site – using straight (X)HTML and not just the javascript widget supplied by Google – you need a tool that can read RSS feeds and display them (the shared items are an Atom feed, but that is similar enough). Using straight links instead of javascript you will be able to pass “link-value” to the items that you are linking to – your links will be seen as recommendations (as in my opinion they should be, if you tagged those items to be shared). I opted to use the Magpie RSS PHP parser. However, you will have to do a slight modification of one of the files in order to process and display the feed properly.

With the original files, Magpie will combine the original URL of the post with the URL of the site itself (and similarly the title of the post with the title of the site). One solution would be to use Feedburner’s “feedconvert” feature to convert the feed with the shared items from Atom into a normal RSS feed – however, by doing that you will lose the title and URL of the site (only keeping the title and URL of the post).

The Magpie files are also included in the WordPress installation (in /wp-includes/rss.php), instead of modifying them (and asking for trouble the next time you update WordPress) I decided to create a copy of Magpie and modify that. The changes aren’t very complicated.

The steps required to set this up are:

  1. Download a copy of Magpie from SourceForge as well as my modifications and test page
  2. Create a folder on your website for Magpie, place Magpie there.
  3. Create a folder for the cache (otherwise it will try to get the feeds every time the page is accesses), adjust the folder permissions to allow your code to write to it.
  4. Modify the test page (use your feed instead of mine, set the cache folder properly) and try it out.
  5. Copy + paste part of the code into your site’s template, add the CSS to your site’s stylesheet.
  6. Done! Start sharing items :-)

The current version of these modifications is v1.0 from July 28, 2007.

There is one trackback ping to this post.
  1. […] Download the following rss_parse.inc.txt file (thanks to John Mueller) and save the file as rss_parse.inc (I.e. remove the .txt extension). IMPORTANT: this file replaces […]

There are 9 comments to this post.
  1. Thank you, you saved my day. I was looking for a solution for hours.

  2. hey they’re starting to throw up some really generic templates for the shared items page. any word on modifications in that area?

  3. I’ll have to give this a shot. I’ve been trying to implement my google reader feed and couldn’t get it to unscramble. Thanks for posting about it!

  4. Just what I was looking for. Many thanks.

  5. Thank you. I was just about to hack Magpie myself but decided to do a quick search. I’m glad that somebody already solved the problem :)

  6. Thank you! Thank you very much!

  7. Simply stuck at parsing the category term=”…” title in ATOM feeds. Anyone has modification for that?
    Regards
    Ugur

  8. I have no succes in getting more than 20 items displayed. The program allows for setting ‘maxitems’ to any number. But apparently 20 is the limit set elsewhere in the process (though I do have more than 20 items in my google reader). Anybody tried this? What is the reason and how can it be put to greater than 20?

  9. thanx!! great script!! just what I was looking for :D

Feel free to leave a reply to this posting.

Warning! Your comment will be lost if you mistype the spam-test or forget to enter your name or e-mail-address. Copy your comment to the clipboard to be sure.

You may use these tags within your reply: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>