Exploring the OpenMail API

Enable the Subscriptions block here!

The recent introduction of the OpenMail API is the latest addition to AOL's set of messaging and communication APIs. This post will walk through the process of accessing this API using ColdFusion 8.

Although we have been working with the Open Blog API for the last couple of weeks, I just had to dig in and check out the new features of the OpenMail API. It's no surprise how easy it is to access the mailbox properties of an AOL account. This example works with the existing framework we created a few weeks back in the posts on OpenAuth. It is assumed you are familiar with and have used the AOL.OpenAuth component in the AOL CFC project. If you're not familiar with this project, that's okay too. Just download it and try it out. It includes full documentation to help you on your way. Once you're up and running with OpenAuth, use the following code to access the new mail count:

<!--- call the service, assuming an OpenAuth component instance available
         in session memory. --->
<cfhttp url="http://api.mail.aol.com/mail/newMailCount" method="get">
    <cfhttpparam type="url" name="f" value="json" />
    <cfhttpparam type="url" name="devId" value="someAOLDevId" />
    <cfhttpparam type="url" name="a" value="#session.obj_openAuth.getAuthenticationToken()#" />
</cfhttp>

<cfset st_mailCount = deserializeJSON( cfhttp.FileContent ) />

The code above is a simple HTTP request to retrieve the new mail count from an AOL mailbox. The request is simple, all you need to provide is the format you wish to receive back (JSON or XML), a valid AOL developer ID, and an authentication token obtained from a successful OpenAuth authentication. Here, I've chosen JSON as the response as ColdFusion 8 now natively supports this format. Dumping this response to screen yields the following data structure:

This example worked through the process of obtaining the new mail count in an AOL mailbox, however that's not where the capability of this API ends. To learn more about how to extend this example and get the details of new mail, check out the OpenMail API reference.