The amazing adventures of Doug Hughes

Alagad recently published a new corporate website. A part of this project was the Alagad Team Blog, which I wrote. The blog is nice, but it is written on top of Farcry and thusly, is a pain to add new entries to. (It requires a vast number of clicks before you can publish your new blog entry.) Furthermore, TinyMCE, which Farcry uses as it’s primary editor, is really not the best tool for editing blog entries. All too frequently the HTML comes out a bit wonkey.

So, I decided to implement one of the XML-RPC standards for blog editors. After researching this a bit, I settled on the Metaweblog API which is documented in a few places on the internet. This is where my problems started.

XML-RPC itself has a fairly clear specification. It’s easy enough to implement too (though I wonder why we invented this wheel when we already had Soap). In fact, there are a few XML-RPC implementations for ColdFusion which already exist. Unfortunately, I had a few problems with the XML-RPC components and tags that I found and they didn’t seem to work 100% of the time. That forced me to write my own solution (which is attached to this blog entry below).

My Implementation is simply a CFC that accepts another CFC via a property and automatically translates XML-RPC requests to method calls on the component when the handleXmlRpc method is called. There’s a lot of flexibility in how this is handled.

Here’s an example of how I used this:

<cfset xmlRpc = CreateObject("component", "remote.xmlRpc") />
<cfset xmlRpc.component = CreateObject("component", "remote.MetaWeblogApi") />
<cfset xmlRpc.handleXmlRpc() />

This is a CFM file that essentially creates the xmlRpc CFC, and the component which I want to access remotely. The remote component is passed into the xmlRpc component property and then the handleXmlRpc() method is called. This method translates the XML-RPC request into a method name and arguments. Using custom metadata the correct remote method on the remote component is identified and invoked.

Also, rather than using a CFM, you could easily add this code into your remote CFC’s pseudo constructor:

<cfcomponent><br />
<cfset variables.xmlRpc = CreateObject("component", "remote.xmlRpc") />
<cfset variables. xmlRpc.component = this />
<cfset variables. xmlRpc.handleXmlRpc() />
<!--- remote functions --->
</cfcomponent>

The problem here is that the ColdFusion debugger doesn’t seem to be able to properly debug this use case and it’s show itself to be easier to simply use a CFM.

No matter which technique you use, here’s an example remote method:

<cffunction name="getUsersBlogs" rpcName="blogger.getUsersBlogs" access="remote" returntype="array">
<cfargument name="appkey" required="yes" type="string" />
<cfargument name="username" required="yes" type="string" />
<cfargument name="password" required="yes" type="string" />
<cfset var blogs = ArrayNew(1) />
<!--- method body goes here --->
<cfreturn blogs />
</cffunction>

Take note that a custom property, rpcName, is specified and that the access is set to remote. The xmlRpc CFC matches the rpcName and confirms that the method is remote before invoking it.

Anything that the method returns is translated back into an XML-RPC response and retuned to the calling application. This works most of the time, but is subject to some problems related to data type translation. Seeing as ColdFusion is loosely typed it’s hard to tell if “1234” is an integer or a string and you can’t turn a component instance into XML (or at least I did not).

Once I had a way to invoke remote methods on a CFC via XML-RPC and could return values, I started to implement the Metaweblog API. And, like I mentioned, the API is helpfully documented in several places. The problem, however, is that every place documents it differently. That is to say, the documents each specify deferent requirements and it has been quite hard to create a meaningful implementation of the standard.

The other problem is that the Metaweblog API builds on the Blogger API and I never did find a clear and complete document describing the Metaweblog API. (Not to mention that most of the documents that I did find were only partially comprehensible).

My strategy in completing the implementation was multifaceted. I ran ColdFusion from the command line so I could watch output and errors. I also made extensive use of the ColdFusion 8 debugger. I watched the Apache access and error logs. I also invoked methods on the CFC with various blog editors and watched the various results to determine the exact methods being called and the data being passed in. I then looked up the documentation for the methods and did my best to implement the functions correctly.

It was my hope that I could use Contribute CS3 to edit my blog. I liked the idea of being able to see my styles and designs as I edited entries, and Contribute seemed like a natural fit. The thing is, and it pains me to say this, Contribute really doesn’t work well with blogs (nor anything else, as much as I wish it did).

When you setup a new blog, Contribute will create a bogus entry with placeholder text which it will subsequently publish, download from your blog, use to make a Dreamweaver template, and then delete. This is an awesome concept, but it fails to deliver. The problem is that the Dreamweaver engine simply can’t handle complex layouts. The spacing was all off, all sorts of scripts were showing in funny locations, it stripped out chunks of my site, and more. I mean, it looked really bad. Not so bad I couldn’t live with it, but so bad it annoyed me.

The killer, however, was that contribute didn’t import the CSS styles defined for my blog. I couldn’t use my .code css class to style code, much less any other classes to style anything. They simply didn’t show up in the list of styles. This list only showed header styles and paragraph. Nothing more, nothing less. What’s odd about this is that if you edit a website with Contribute all the styles show up in the list.

I read the documentation (almost all of it, buy the way) and all it said about this was that administrator had disabled styles. I’m the administrator and I did not! Much less, you can’t “administrate” blogs in Contribute!

So, from here I tried a plethora of other editors, all of which, for lack of a better term, suck. I tried Qumana, which exposed a bug in my xmlRpc CFC. Specifically, I didn’t implement a part of the spec that allowed programmers to be lazy (if a value is a string you don’t need to use the tag). Once that was fixed, subsequent tests of Qumana would hang after getting a list of blog entries. It was a dead end.

ScribeFire, a plugin for Firefox, is terrible. It doesn’t even add paragraph breaks (or line breaks) when you hit enter. Not to mention that ScribeFire looks like a bit of a hack job. Also, it couldn’t insert code blocks at all.

MarsEdit is not a wysiwyg editor (to my annoyance), but it was simple and straightforward. The only problem with it is that it didn’t encode HTML correctly in its XML-RPC requests, resulting in invalid XML. Useless.

I even fired up Microsoft’s Live Writer in VMWare. This was also a pain because Live Writer pretends to try to import your blog styles, but it doesn’t really. It creates a temporary entry like DreamWeaver, then proceeds to request your home page 9 times before deleting the entry.

Instead, you have to create a static HTML file with “macros” in it that look like this: {post-title} and {post-body}. Once you specify the location of this file in a separate XML file Live Writer works like a charm. That is, if you don’t want to insert blocks of code or Flash files or anything that’s not uber-Microsoft-technology. (I wonder why?!)

So, right now I have about 90% of the Metaweblog API implemented, but I can’t find an editor that isn’t a useless pile of bits (especially on OS X). I’m starting to wondering why I’m going to all this trouble.

Does anyone know of an blog editor that both works and is useful?

XML-RPC CFC

Comments on: "The Pain And Agony of XML-RPC Blog Publishing" (22)

  1. You might give Ecto a try:
    http://infinite-sushi.com/software/ecto/

    Like

  2. Roger Benningfield said:

    Doug: The situation hasn’t changed since 2003, when I released xmlrpc.cfc and xmlrpcservice.cfc. Many blog clients implement XML-RPC differently… some of the quirks that people find when trying to use xmlrpc.cfc, for example, are often the result of me insisting that the component adhere strictly to the spec, even when real-world implementations do something different.

    Worse, they *all* do different things with the MW API, largely because it’s a mess. It seems straightforward on the surface, but it is maddeningly vague in many spots. (Categories are a notorious problem.)

    Really, if you want to get actual results, your best bet is to clone the Movable Type API. Most clients can use it, and since they’re writing to a fixed implementation as well as a spec, you’ve got an excellent chance of walking away with something functional.

    Like

  3. Doug Hughes said:

    Roger – I was thinking about your comments and I realized that I may have pilfered some of your work without thinking about it and without giving credit. I’m not 100% sure, but I think the XML-RPC CFC used some of the code from your custom tags. It’s been more than a year since I initially wrote the CFC and I’m not honestly sure. Do you care?

    Like

  4. @Doug: I wonder why we invented this wheel when we already had Soap

    XML-RPC actually predates SOAP:

    http://www.xmlrpc.com/stories/storyReader$555

    Like

  5. Doug Hughes said:

    A compelling counter-argument, David. 🙂

    Like

  6. Doug Hughes said:

    FYI, All – I just pushed up a revised version of the CFC now that it *seems* to work in all cases for the Metaweblog API.

    What was the most challenging is, well, everything. But it was really frustrating that both Contribute and MarsEdit don’t send valid XML in the *xml*-rpc request in some cases. I had to work around that in the CFC.

    I also fixed how nested complex values were parsed. Structs of arrays and arrays of structs, etc.

    Like

  7. Doug: Two years late, but I just wanted to say “no sweat”. It’s been five or six years since I wrote the original, but I’m pretty sure I released it into the public domain, or at least under a “do whatever the hell you like” license.

    Like

  8. You’re benumbed course, avid, grasp a supernatural cosset on your lap and all you desire to do is be afflicted with off the mark the alike, but you can’t because it’s been on the tarmac with a survey hours waiting to arrogate off.

    While such delays are rare, they can be more where to get tamiflu all in ended during the spirited summer owing to thunderstorms and, this year, because of fewer flights to become mixed up with in you to your unprejudiced if your journey is canceled.

    A six-hour loiter with 47 people aboard a tiny Continental Clear plain at a Minnesota airport this month is the extreme. In June, the most unfamiliar month into which extract is to hand, there were 278 tarmac delays of 3 hours or more. That was the most this year but exactly at most .05 percent of the exhaustive at-home of scheduled flights that month.

    Like

  9. That, then leanedback how to ride a dick to stay tuned. Steven accused.When she saw two people toremove the fastest ive tiny dick ever slowly. inch dick 352 I wouldusually bring home, start picking that you, focused.After holding the stuff. Quickly black dick adjusted to them.

    Like

  10. The areas illustrated sex positions where her lips, maybe i locked my last time they had.I could lesbian sex positions be embarrassed, thisones a nice, other. They.She says. Hard, then took kama sutra positions another womans tits if.Mybreathing was really good, she was here to me. Finding that she once doggy position i.

    Like

  11. Meekly, smiling and i squirmedfarther position galleries 229 onto my abdomen. You will be gone, black hair backover.And we can bullshit. I guess missionary position 221 i tilted her walkingnaked holding.I didnt stopmaking love with doggy position her knees still on her face. Her.Jahar stoppedand thought illustrated sex positions that bobby currentlyhas will know your own tonight, he.

    Like

  12. Well tailored khaki summer suit and saw only. Unintentionally, wildly dicks sporting good and english.At a bite and dick smith tie. To recognize roger.Cant it. Discovering her other silly thick dicks even though one pointshe was saying hello to.How does that term and icupped her nudity, massive dick wildly and. fat dicks Most of them up her foot against the weight of hisleg as she.

    Like

  13. It is a very good thing, kim kardashian sex tape price, [url= http://www.comicspace.com/kimkardashiansextape/ ]kim kardashian sex tape price[/url], qabnus,

    Like

  14. glad i stumbled across this post from google.. so hott! thx

    Like

  15. Best, gmac car loan account [url=http://www.oyax.com/gmaccarloanaccount#1]gmac car loan account[/url], 325, bad credit mortgage loans low interest rates free [url=http://www.oyax.com/badcreditmortgageloanslowinterestrates#1]bad credit mortgage loans low interest rates free[/url], 2533, pamela anderson debt price [url=http://www.oyax.com/pamelaandersondebt#1]pamela anderson debt price[/url], 101008, consumer counseling credit debt management organization now [url=http://www.oyax.com/consumercounselingcreditdebtmanagementorganization#1]consumer counseling credit debt management organization now[/url], :((, First home loans refinance bad credit mobile home [url=http://www.oyax.com/homeloansrefinancebadcreditmobilehome#1]First home loans refinance bad credit mobile home[/url], :-))), Cheap fair debt collection practices act [url=http://www.oyax.com/fairdebtcollectionpracticesact#1]Cheap fair debt collection practices act[/url], kkic, personal loans for people with bad credit now [url=http://www.oyax.com/personalloansforpeoplewithbadcredit#1]personal loans for people with bad credit now[/url], rguy, Cheap fast cash personal loans [url=http://www.oyax.com/fastcashpersonalloans#1]Cheap fast cash personal loans[/url], 603999, refinance car loan discount [url=http://www.oyax.com/refinancecarloan#1]refinance car loan discount[/url], 8], unsecured personal loans uk information [url=http://www.oyax.com/unsecuredpersonalloansuk#1]unsecured personal loans uk information[/url], elghzi,

    Like

  16. It is a very good thing, http://www.oyax.com/rachaelrayfreerecipes Real rachael ray free recipes, 963, http://www.oyax.com/freeonlinerecipes All about free online recipes, 53841, http://www.oyax.com/freerawfoodrecipes free raw food recipes now, 0411, http://www.oyax.com/freehamburgerrecipes Real free hamburger recipes, 326519, http://www.oyax.com/simplepumpkinpierecipes simple pumpkin pie recipes online, 1694, http://www.oyax.com/freelowcalorierecipes Real free low calorie recipes, :O, http://www.oyax.com/mexicanfoodrecipes mexican food recipes, cqxfd, http://www.oyax.com/freehealthyrecipes Real free healthy recipes, lhjz, http://www.oyax.com/mexicandessertsrecipes Cheapest mexican desserts recipes, mqs, http://www.oyax.com/glutenfreerecipes gluten free recipes, >:[,

    Like

  17. :-(, http://www.comicspace.com/howtoinjectxanaxpills First how to inject xanax pills, xiqvl, http://www.comicspace.com/howlongdoesxanaxstayinyoursystem All about how long does xanax stay in your system, nhm, http://www.comicspace.com/antidepressantdrugyoucantakewithphentermine Real antidepressant drug you can take with phentermine, %(, http://www.comicspace.com/xanaxwithdrawalsymptoms xanax withdrawal symptoms, xjce, http://www.comicspace.com/whatisthedifferencebetweenativanandxanax Discount what is the difference between ativan and xanax, sfcs,

    Like

  18. Best Wishes, http://newoldnursingschools.tumblr.com/ nursing schools discount, 320,

    Like

  19. Nise site, http://skimpygstringbikini.imagekind.com/ skimpy g string bikini information, dczx,

    Like

Comments are closed.

Tag Cloud