Skip to content
Jorge Reyes edited this page Jun 3, 2015 · 1 revision

While the feedReader plug-in has a number of methods, most of the time you will only ever need to use readFeed(feedURL) to retrieve feeds. This method will first look to see if there is a local, cache copy of the feed that has not expired. If that was not found it will retrieve the feed online using the URL provided by feedURL. The feed will be parsed and saved as a structure with the feed's items contained within a query.

 <cfset rc.myFeed = getPlugin("feedReader").readFeed("http://www.example.com/rss")>

A basic event to read and parse the ColdBox Blog News RSS feed.

<---  Read & Parse the ColdBox Blog News Feed --->
<cffunction name="dumpFeed" access="public" returntype="void" output="false">
 <cfargument name="Event" type="any">
 <---  RC Reference --->
 <cfset var rc = event.getCollection()>    
 <---  Obtain Feed --->
 <cfset rc.parsedFeed = getPlugin("feedReader").readFeed("http://blog.coldbox.org/feeds/rss.cfm")>
 <---  Dump the Parsed Feed --->
 <cfset Event.setView("vwFeedDump")>
</cffunction>

A simple view to dump the feed. Obviously in a production ColdBox application you would not dump the parsed feed, rather you would process the data returned.

<---  View to Display the Parsed ColdBox News Feed --->
<cfdump var="#rc.parsedFeed#">
Clone this wiki locally