In-page RSS aggregation

During a discussion of “content management” (another hot summer topic) with WUFT-FM’s news director, he pointed out that the NPR news feed that once appeared on his news page no longer was appearing for some reason. I decided to investigate.

The old method involved linking and invoking a JavaScript file from the NPR site and it fed the news to your affiliate page. At some point, NPR dropped support for this and we missed the memo.

NPR is now providing the feeds in RSS format. The problem then becomes one of how to incorporate this data into “our” web page.

We are a Windows server shop. An ASP script would have been the most straightforward way of doing this, but I didn’t like the examples I found on the web and I don’t do .Net (and have no plans to). I have PHP available and thought I’d give it a try since I had read excellent things about the Magpie RSS parser for PHP. It works very well. I quickly had a PHP script working to format the data as I pleased.

I didn’t want to change the URL from default.asp to index.php though because we’ll probably be changing it again in the not-too-far future once we get content management working. That led me to use an object on the server that can retrieve data from one page and insert it into another. The code looks like this:

dim source
set source = Server.CreateObject("Msxml2.ServerXMLHTTP")
source.open "GET", "http://server.name.domain/path/phpfile.php", False
source.send
Response.Write(source.responseText)

And it just works.

This entry was posted in Coding, Javascript, PHP. Bookmark the permalink.

Comments are closed.