JOEZACK.COM Code Musings and Such

8Oct/080

ColdFusion NPR API Pt. 2

I've dug a little deeper into the NPR API. I've added 3 new components. Feed.cfc represents the data returned from the api call. Story.cfc models the actual stories that make up the feed.

The 3rd object is a simple object that I extend to share some common methods to between my other components. I generally consider this bad practice and there are a lot of tools designed specifically to address this problem.

I did it for a couple of reasons. First, I wanted this to self-contained and stand alone. I wanted it to be as easy as possible to drop it into whatever project YOU have, with whatever tools YOU have set up and get it going. Second, I wanted to focus more on the real meat of the product without getting too hung up on the implementation details. Besides, I can always refactor!

Stay Tuned!

Example Usage:

<cfset your_key = "Go get one from http://www.npr.org/templates/reg/"/>
 
<cfset npr_interface = CreateObject("component","npr").init(
	key = your_key
)/>
 
<cfset feed = npr.GetFeed(
	id = "1059"
)/>
 
<cfset stories = feed.GetStories()/>
 
<cfloop array="#stories#" index="i">
	<cfdump var="#i.GetXMLData()#">
</cfloop>

Download the code!

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

(required)

No trackbacks yet.