If you use third-party blogging software (such as MarsEdit), you may have some trouble configuring that client to work out of the box with Drupal.
See, Drupal 6.12 comes with the handy “Blog API” module: it gives your Drupal site an XML-RPC interface. In english, that means that you can post content to a Drupal-based website using client software such as TextMate and MarsEdit. This is nice.
So, assuming http://example.com/ is your drupal install, you can feed an URL of http://example.com/xmlrpc.php to MarsEdit, and happily post and edit content to Drupal. And bunnies and squirrels will dance around the meadow in joy and fling flowers in the air.
Yes.
Well.
In theory, there should be no difference between theory and practice. In practice, there will be.
HOWTO: make Drupal work with MarsEdit
MarsEdit is pretty easy to set up, but there’s one minor hiccup, caused by a bug in Drupal’s blogAPI module. Here’s a quick run through the setup process:
Let’s add your blog to MarsEdit. Select New Weblog... from the File menu. A friendly window appears: “Tell us about your weblog”. Go ahead and plug in the base URL of your drupal site. If the autodiscovery bug I mentioned has not been patched, then you will get a dialog that says, in effect, “I am a stupid computer and cannot figure this out, so you will have to do it for me”. If you don’t get this message, then the bug has been fixed. Hooray!
Otherwise click Edit Settings and you will be presented with a dialog box like the following:

I’ve selected most of the (likely) correct options in this box, but notice the field labeled Blog ID: (helpfully highlighted above). This is where you have to check your settings in Drupal, because you have to choose the type of content you will be submitting via your client.
Drupal allows the definition and creation of different content types. You get to them via the administrative menu, under Administer > Content management > Content types. (This should have the path of http://example.com/admin/content/types in your browser address bar.)
For example, you can see that my site currently has two content types: blog and page:

You’ll notice that the blog type has the Name Blog Entry, and the Type blog.
The type is your Blog ID for MarsEdit.
If you want to create pages of that type with MarsEdit, you want to put blog in to the field marked Blog ID. If you created a custom content type named Wiki Notes with the type wiki, and you want to post those notes using MarsEdit, you want to enter wiki in that field.
And that should work.
Hooray.
HOWTO: make Drupal work with TextMate
The TextMate Blogging Bundle provides a sparse (but pleasant to use) interface for the creation and editing of blog entries directly inside the text editor. I’m using it right now to compose this post.
Sadly, when I tried to access the drupal blogAPI from it, Drupal threw an error: Blog API module is not configured to support the 0 content type
Hmm.
Okay, so content type is basically the blog_id in XML-RPC terms. So I guessed that TextMate wasn’t specifying the blog ID, and was passing the default value (which I know from past, painful experience is 0). So I had to configure TextMate to specify that blog ID value somewhere. But where?
The TextMate Blogging Bundle invokes a ruby script, [$TM_BUNDLE_PATH]/lib/blogging.rb, which parses a file called com.macromates.textmate.blogging.txt. Here, with URLs obfuscated, is mine:
# List of Blogs
#
# Enter a blog name followed by the endpoint URL
#
# Blog Name URL
Paper Bits http://some_path_to_wordpress_stuff
Drupal Blog http://www.example.com/xmlrpc.php#blog
See that bit on the end of the Drupal Blog line? The #blog? That’s where the magic lives.
Translation: To get TextMate working with Drupal’s blogAPI module, put a #typename at the end of the XML-RPC URL.
If your content type is wiki, then you want http://www.example.com/xmlrpc.php#wiki under URL.
And that’s it.
What’s happening here?
In case you care, I found this by digging into the [$TM_BUNDLE_PATH]/lib/metaweblog.rb and [$TM_BUNDLE_PATH]/lib/blogging.rb scripts.
In metaweblog.rb the methods all require a blog_id to be passed along with the method call. An example:
def get_recent_posts(blog_id, username, password, number)
call("metaWeblog.getRecentPosts", "#{blog_id}", "#{username}", "#{password}", number)
end
Okay, so, let’s do a search in blogging.rb for the variable blog_id. We find a method called parse_endpoint which features the following:
def parse_endpoint
# we have an endpoint that looks like a URL
[...]
# guess the mode based on the endpoint path
[...]
if @endpoint =~ /#(.+)/
@blog_id = $1
else
@blog_id = "0"
end
end
Aha. That’s a regular expression. It’s looking for #something at the end of the URL, and setting that as blog_id. And if it doesn’t? It sets “0″. Which is the offending element from my rogue error message.
So, I made a guess, and it worked.
Hot damn.
Moral of the story
This post began as a plea for help to the lazyweb. I had solved the MarsEdit problem (it was a simple matter of a single Google search), but couldn’t manage to get TextMate running.
In order to write this post, I had to explain my problem with TextMate in a clear and concise manner to an educated but unfamiliar audience. Which meant thinking along lines like, “well, they’re probably going to ask me if I looked to see if TextMate submits a blog ID like MarsEdit. I wonder where that would be kept?”
Eventually, I solved my own problem.
I hope that the next time someone else has the same problem, the great Google technical support repository pops this article up for them, and saves them some time and pain. If that’s you, then excellent.
If you’re still having trouble, try writing an email to the smartest person you know. You might end up solving it yourself.
Good luck.








