AOL Pictures and ColdFusion 8

The AOL developer blogs have been cooking pretty good here for the last week or so with some very good examples of interacting with the various APIs. There's been quite a bit of C# and Perl represented so I thought I would take a moment to show how easy it is to incorporate some of the new features of ColdFusion 8 which recently shipped.

One of the great things about the AOL APIs is the accessibility to every level of developer talent. Whether you're a hardcore JavaScript person that likes to hang more on the client side or a server side guru, there's plenty of space for everyone to get a chance to create some interesting mashups.

Coupled with the accessiblity and simplicity of many of the AOL APIs is the now native support for serializing and deserializing JSON formatted data in ColdFusion 8. I've always found ColdFusion such a great platform to develop web applications due to its enabling of rapid development. Using the AOL APIs as a ColdFusion developer is very easy to get started and is quite natural. Here's a simple example involving the AOL Pictures API running a query for pictures tagged as 'camel' (couldn't resist a Perl reference).

<!--- step 1: run a search for all pictures tagged as 'camel' --->
<cfhttp url="http://api.pictures.aol.com/gv1/pictures/getTaggedPublicPhotos?f=json&devId=someID&h=host&locale=en_US&tag=camel"
		method="get" />

<!--- step 2: response is JSON, deserialize --->
<cfset json_response = deserializeJSON( cfhttp.fileContent ) />

<!--- step 3: it's a cf data structure, do as you please --->
<cfloop from="1" to="#ArrayLen( json_response.response.data.pictures )#" index="i">
	<!--- shorten up the reference to the current picture --->
	<cfset picture = json_response.response.data.pictures[i] />
	<cfoutput>
    	    Login id: #picture.loginId#<br/>
            <img src="#picture.sizes[1].url#"
        	    height="#picture.sizes[1].height#"
                    width="#picture.sizes[1].width#" /><br/>
        </cfoutput>
</cfloop>

In its simplest form, running a query for tagged pictures against the AOL Pictures API is as easy as three steps. Step 1 involves executing an HTTP request passing the required parameters in the querystring. Step 2 uses the new deserializeJSON( ) function to get the JSON formatted data in to a native ColdFusion data structure. Step 3 is whatever you want it to be. Here I just output the login id and picture.

Through the coming weeks, I will be creating ColdFusion components (CFCs) which can be used to interact with the various AOL APIs. Check back early next week when I update this posting for where to download the AOL Pictures CFC.