Using MagpieRSS To Create An AJAX RSS Reader

23 Jun

When I recently redesigned this site, one of things that I got asked about the most was my Flash RSS parser. I built it in an attempt to try and ‘reedem’ Flash a little as it occassionaly gets misused in terrible ways and I thought it would be nice to see some practical, useful Flash applications.

However, its very limited. I can only parse RSS 2 feeds which excludes Atom users totally and seeing as a lot of my favourite authors publish in Atom I needed a way to parse this data too. I could’ve adjusted the RSS parsing engine that Flash used to accomodate Atom feeds but then I realised I was making life much more difficult than it needed to be. It seemed to me that switching to MagpieRSS which already accomodates all these feeds would be a much easier proposition. But then, the reason I wanted to use Flash would be lost – and if I used MagpieRSS then I’d need to refresh the page every time a new feed was selected.

Obviously you can see where I’m going with this; the next stage in my thinking was ‘is it possible for me to adjust MagpieRSS to serve its results via AJAX?’.

I didn’t know. Mainly as I’ve never used MagpieRSS before and neither have I written anything using the AJAX methodology before but I thought it might be interesting to find out and (as always, the best thing) teach me something new. So, the first step was to learn about how AJAX worked. As I understand it, AJAX can only be triggered through variables sent from form elements i.e. you can’t send data via a querystring appended onto a URL. This would mean some minor hackery on my part.

So, my AJAX application would entail a few distinct sections. First would be the links that a user would click to select a feed. This would then send the value of the name/value pair appended to these links to a hidden form field and hence make this value available to the AJAX toolset.

Next we turn our attention to our Javascript and setting up the XMLHTTP objects:

Next, the field value is turned back into a query string and appended to a URI that is sent to the behind-the-scenes MagpieRSS script. The MagpieRSS script then does its thing and our AJAX script returns the results back to our page and displays them in a div.

This is really a no-brainer. Because all the hard work is done by the MagpieRSS script it makes the job much easier. All I really had to do was fit it into the traditional AJAX framework. You can see the results here along with all the bits I couldn’t fix to make the page validate. Maybe you’ll have some ideas on how to do these things or maybe you can re-write this whole thing much better. Either way, I’d like to hear about it.

Its not live on my site yet as I haven’t found time to style it to my satisfaction but I can think of ways this will benefit the websites I work on as well as my personal sites.

11 Responses to “Using MagpieRSS To Create An AJAX RSS Reader”

  1. John Oxton June 23, 2005 at 12:11 #

    Very cool Kev, I will have to have a look at this a little closer! 🙂

  2. Helen June 23, 2005 at 14:31 #

    completely off topic for this post but have you seen this:

    http://news.bbc.co.uk/1/hi/technology/4115806.stm

  3. Kev June 23, 2005 at 14:37 #

    Comes as no surprise Helen :o)

    The majority of developers who come through here will almost certainly be users of Firefox and very much part of that (lamentably small) percentage of developers who code for standards rather than browsers. Our job is partly evangelising browsers like Firefox, Opera and Safari to a wider audience.

    Thanks for the link though – adds to the growing clamour if nothing else.

  4. Matt Setchell June 23, 2005 at 23:19 #

    How much does it cost to hire you for mattian again 😉

  5. Tom June 23, 2005 at 23:32 #

    Very slick indeed, if you did want to use Flash you could use Magpiee to turn into a simple RSS feed, which you could reparse in flash.

  6. Matt Robin June 23, 2005 at 23:55 #

    I just love the way it’s called an ‘AJAX RSS Reader’…to us that makes some hint of sense, we know what you mean, but I could imagine the look on the faces of some non-geeks if they read this – it would be like an alien language to them!

    Good post Kev – I’ll take a closer look at the code either tomorrow…(no, wait, I’m busy tomorrow – maybe at the weekend then)

    Hope all is going well with you and yours.

  7. Matt Setchell June 24, 2005 at 23:54 #

    your code kinda overlaps into the right hand screen area in Firefox on XP with SP2 btw

  8. T.Willmot June 25, 2005 at 14:46 #

    A really nice idea, will look more into it when I get chance.
    Could be the start of a WordPress plugin.

  9. David March 9, 2006 at 16:23 #

    este manual está muy útil
    lo podrías subir al wiki-manual.com

  10. david March 9, 2006 at 16:24 #

    Mierda de corrector…
    Que digo que el manual esta muy util y lo podias subir a http://www.wiki-manual.com

Trackbacks/Pingbacks

  1. .::PHPVietnam.net::. » MagpieRSS và AJAX RSS Reader - June 23, 2005

    […] CSS | Home 24/6/2005 MagpieRSS và AJAX RSS Reader Bài viết này rất cool. Cat:  PHP | Time: 12:19 am  […]

Comments are closed.