the singularity of being and nothingness
ColdFusion and Technorati – A Quick Example
Today, a client of mine (deviantmonk.com ) contacted me and requested that I set up a way for Technorati to be updated when posts are created and updated.
Although I have certainly heard of Technorati , until today I had not had any exposure to everything that it does. One feature is that it acts as a blog aggregator of sorts. Admittedly, it has some nice functionality: besides displaying posts from blogs, it also includes comments and is smart enough to get username and avatar information. The downside is that Technorati–like Google and other content aggregators–only update sites as their bots get to them. Obviously, left to itself, this can take some time, and posts which were made yesterday could not appear for several days (or longer).
Fortunately, Technorati has a nice webservice that allows users to ping the server to alert it to changes to the blog content. Admittedly, the update still takes about 10 minutes, but that is still better than the unacceptable alternative…
So anyway, the webservice is extremely simple. I wrapped up the relevant code in a nice ColdFusion function and simply invoked it on the end of my normal post processing. The enitrety of the code is as follows:
<cfxml variable="technoratiXML">
<methodCall>
<methodName>weblogUpdates.ping</methodName>
<params>
<param>
<value>BLOG NAME HERE</value>
</param>
<param>
<value>http://www.BLOGLINKHERE.com/</value>
</param>
</params>
</methodCall>
</cfxml>
<cfhttp method="post" url="rpc.technorati.com/rpc/ping" >
<cfhttpparam type="xml" value="#technoratiXML#"/>
</cfhttp>
</cffunction>
In short, I create basic XML content with ColdFusion and then use cfhttp to send an XML-RPC message to Technorati. It really could not be easier.
To extend this a bit further, one could do some error checking on the response from Technorati. The ping request sends back a message which includes errors if the ping fails, too many subsequent pings are made, etc. I am just being lazy with posting this example here…
More fundamentally, however, this has highlighted the usefulness of ColdFusion components to me. Because all of my functions are entirely encapsulated in components, adding this bit of functionality to the overall blog engine was incredibly easy and did not require massive changes to ANY processes. All I did was create a new function and then add its invocation to the series of invocations created in my regular blog creation and update processes. In short, beyond the dozen or so lines above, only one additional change was necessary to get this up and running. I am no programming guru, but in my mind that is pretty powerful in that I can now turn my attention to doing more important coding.
Anyway, there is nothing spectacular going on in this code, and I know that others have done it more robustly than I have (e.g., Ray Camden's BlogCFC ). However, I thought it might be helpful as a short example to someone trying to find a quick answer to this issue.
Print article | This entry was posted by existdissolve on December 16, 2007 at 4:45 am, and is filed under ColdFusion. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |