msgbartop
by Joe Zack
msgbarbottom

30 Sep 08 ColdFusion NPR API Pt. 1

NPR published an API a while back giving easy access to 250,000+ NPR stories.

As I'm still quite the newb when it comes to Object-Oriented Programming I thought I would blog through the process of creating an OO ColdFusion wrapper.

Example Usage:

<cfset your_key = "Go get one from http://www.npr.org/templates/reg/"/>
 
<!--- create the object --->
<cfset npr_interface = CreateObject("component","npr").init(
	key = your_key
)/>
 
<!--- pass you some ids --->
<cfset result = npr_interface.Get(
	id = "1059,1008"
)/>
 
<!--- voila --->
<cfdump var="#result#">

Download the code!

PS: In order to actually run this you'll need to register for an account and API key. Also, browse the aggregate to ID mapping info to find yourself some id's to use!

PPS: A much-love shout-out to my local NPR affiliate WMFE. Support publc radio!

Tags: ,

Leave a Comment