A few days ago I blogged about an Aggregator UDF I was working on. This UDF took a set of RSS feeds and returned a "joined" query, like MXNA, FullAsAGoog, or Feed-Squirrel. I've worked on this a bit more and have updated it to be a full CFC. I've made some interesting changes I think folks may like as well.
First off - the CFFEED tag returns a query that contains as much information as possible about the RSS feed. But if you are working with dynamic/multiple feeds at once, it is a bit difficult to write one query to output the results for all of them. So for example, the linkhref column is used for Atom feeds while rsslink is used for RSS. In order to use the right column, you would normally check the metadata returned from the cffeed tag. Consider this example from the ColdFusion 8 docs:
<cfoutput query = "myQuery"> <cfif myProps.version IS "atom_1.0"> <h3><a href = "#linkhref#">#title#</a></h3> <p><b>Published:</b> #DateFormat(publisheddate)#</p> <cfelse> <h3><a href = "#rsslink#">#title#</a></h3> <p><b>Published:</b> #publisheddate#</p> </cfif> <p>#content#</p> </cfoutput>
So one of the first things I added was a new column, link. This column will contain the appropriate column based on the feed type.
Another problem is the difference in date formats. Atom has a format and RSS has another format. Again - don't worry. I combine this into a new Date column. (Thanks to Jared for help parsing the Atom feed.) This fix also makes the sorting work nicer as well.
So along with an aggregator method, I added search. Want to search RSS feeds for a particular search term?
<cfset aggregator = createObject("component", "aggregator")> <cfset feeds2 = "http://weblogs.macromedia.com/mxna/xml/rss.cfm?query=byMostRecent&languages=1,http://www.riaforge.org/index.cfm?event=page.rss,http://feeds.feedburner.com/RaymondCamdensColdfusionBlog,http://www.protogenius.com/atom/example-03.atom">
<!--- Test Search ---> <cfset results = aggregator.search(listToArray(feeds2), "ray")> <cfdump var="#results#">
So test it out and let me know what you think. This will be the core of my new RSSWatcher.com site, when I find the time to build it. ;) If you use the sample code above, you may notice MXNA doesn't return a value from dates. This is a known bug in CFFEED and has been reported.