After reading a post on the CF-Talk earlier this morning about blogging APIs it was suggested to look into Roger Benningfields XML-RPC CFC (read about it here).
So I’ve been doing just that and it really is quite cool. Basically the CFC handles the conversion of CFML to and from XML-RPC packets so you don’t have to worry about any of that. I use Newzcrawler as my RSS aggregator so i set about figuring out how to use it to add entries to my blog. In Newzcrawler you have to define ‘my Blogs’ the XML-RPC API they each use, along with the host and the RPC end point. Newzcrawler then goes off and retrieves a list of available blogs on the server. This is where the fun begins.
So, armed with the CFC i started with:
<cfinvoke component=”hosta.cfcs.xmlrpc”
method=”CFML2XMLRPC”
returnvariable=”rpcCall”
data=”#myArray#”
type=”response”>
<cfmail from=”x” to=”x” subject=”XML-RPC request”>
<cfdump var=”#rpcCall#”>
</cfmail>
to see what Newzcrawler wanted to do first. When you receive the email you see that it first wants to call the method blogger.getUserBlogs so that’s what i started out by researching what i needed to send back to the client.
Links of worth at this point are here and here which define the specs of the various XML-RPCs. Blogger.getUserBlogs needs to return data as per here so i need to make ‘myArray’ an array containing a structure before processing with the XML-RPC cfc, so far i’ve got;
<cfset myArray = arraynew(1)>
<cfset data = arraynew(1)>
<cfset member = structnew()>
<cfset member.url = “http://www.beynon.org.uk”>
<cfset member.blogID = “22146F3D-B577-7592-447884894DEBBB88″>
<cfset member.blogName= “John Bs personal blog”>
<cfset data[1] = member>
<!— nest the arrays —>
<cfset myArray[1] = data>
which setups the particular blog within Newzcrawler when you pass myArray into the CFC and then ‘update’ the blog list from Newzcrawler.
So far so good, I’m still fine tuning the ‘posting’ from Newzcrawler, this entry was made from it - but no category assigned on posting. More to come soon….
Recent Comments