How do you get around this issue? Well, a php based proxy is one solution. You call via AJAX, this php file that then makes the request to the real feed, and sends it back. That didn’t seem like a simple or elegant enough solution.
I found RssToHtml, which is a PHP script that you can use the parse the RSS feed. Using this, you can even use an server side¬†include to get the feed. This¬†didn’t work on my machine¬†that would only¬†run cgi scripts from the include.¬†
I had just about given up when I stumbled upon the Google AJAX Feed Api. Google to the rescue again.
The first thing I tried was a wizard that created feed code for you. It presents a cool little AJAX box that can rotate through a feed list. This is what it looks like for one feed (see example page also) :
This is what it looks like for multiple feeds (see example page also) :
But this still wasn’t quite what I wanted. It was a little too flashy. I really just wanted a list of posts, with links to them. I then found the API page (that I mentioned above) and some more basic examples.
This is what I got (see example page also) :
There we go. That is what I was looking for. Ok, so what do you have to do to get this same result? First you should get a google api key. If you are grabbing code from me, don’t use my google code. Get your own, or use “key=notsupplied-wizard” instead.
You really need three pieces. You need to point to the google search API:
The basic example on the site does not show links. I had to build that. The result that comes back is a json object that contains info about the feed. I discovered that for every "entry" there was not only a "title" but a "link". I used the "link" property to build an anchor tag to wrap the title. Now when the list is presented, a viewer can click on the text and go to the post. If you want to present more info, "publishedDate" and "content" are two other attributes you may want to use.
It works pretty well. Google caches the feeds too. Not sure how that is done, or how fast it is refreshed, but it sure is darn fast. I like it. Give it a try.