D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Javascript Feed Reader

 

On 8/29/07, Jonathan Roberts <jonathan.roberts.uk@xxxxxxxxxxxxxx> wrote:
> Anyone got a suggestion for a javascript based RSS feed reader that I
> could use? All I want to do is display the latest headlines from a
> website, linked to the original source, in another website - does that
> make sense?
>
> I've been trying to put something together myself but as it turns out
> XMLHTTPRequest and DOM isn't the easiest thing in the world (at least
> not for my mind) and I was wondering if anyone knew if there was an
> open source system already existing...

I'm sure Google will come up with something. The DOM might be
confusing at first, but it's not rocket science either and lots of
people have been in the same situation before.

The main problem is that "another website" is most likely to be on a
different domain and XMLHTTPRequest doesn't work cross-domain. A
simple work-around for this is to write a PHP script that just grabs
the feed from the other website and outputs it and then use this
script in your JavaScript.

But then, if you start using PHP, you may as well make your PHP script
into a XML Parser that reads the RSS and outputs it in the way you
want to include it into your website. This way you can avoid
JavaScript altogether, which is probably a good thing for several
reasons. Moreover, this way you can store the data in cache somehow
and read it from there and only grab it from the other website every
now and again. (Which may still be every minute, but if your site gets
very popular, it will keep both your webserver and that of the other
site happy.)

(I use this method to include last.fm's most recent tracks into my
blog. It wasn't my idea though and the WordPress plugin I used for
this wasn't mine either.)

Alternatively, you could proxy the remote URL. This is not too hard a
thing to do, but you need to be able to edit the Apache config file,
which you probably won't if you just have your site hosted somewhere
else than on your own computer.

Both methods are described here:
http://www.xml.com/pub/a/2005/11/09/fixing-ajax-xmlhttprequest-considered-harmful.html

I realise though that probably isn't an answer to your request for a
simple downloadable method, but I hope it helps a bit anyway.

Martijn.

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html