You are here:
Microsoft SQL 2008 Database Server Microsoft SQL 2008 Database Server

How to issue a Trackback using Adobe ColdFusion and CFHTTP

I've been meaning to get round to having the ability to issue Trackbacks and Pings using my custom built CMS, but also provide my site with the ability to receive Trackbacks and display them for genuine comments and credits from other websites.

I stumbled across a neat little post by Pete Freitag titled Trackbacks with ColdFusion that details how to accomplish this in a few lines of code. Simply using CFHTTP, you can post and credit other websites for their hard work and for saving you time banging your head against a brick wall with a development problem. The example code works as follows:

<cfhttp url="http://www.trackbackposturl.com/" method="post">
<cfhttpparam name="url" value="http://www.blog.com/my-blog/xxx-xxx/" type="formfield" />
<cfhttpparam name="title" value="The Title of My Post" type="formfield" />
<cfhttpparam name="blog_name" value="My Blog Name" type="formfield" />
<cfhttpparam name="excerpt" value="A short excerpt of the posting" type="formfield" />
</cfhttp>

Now for the XML response. You can simply read the contents of the CFHTTP response using cfhttp.filecontent. If there is a successful response, you should receive an XML response as follows:

<?xml version="1.0" encoding="utf-8"?>
<response>
<error>0</error>
</response>

If there is an error in your submission, you will receive a response like the following:

<?xml version="1.0" encoding="utf-8"?>
<response>
<error>1</error>
<message>The error message</message>
</response>

Works like a charm. Thanks again to Pete Freitag for the great simple example. Enjoy!