Tip: Eager to take advantage of Dashboard, Sean Gallagher has begun building a widget to serve as a client for Blogger API, and he explains how he got started.Now that I've got Dashboard, I want to use it for something I do every day: blogging. So, I'm working on creating a widget that acts as a simple client for the Blogger API.
OK, so before all the bloggers out there get all fundamentalist on me, I want to explain why I'm using the Blogger API instead of something more au courant like Atom, or even the MetaWeblogAPI: It's no-brain simple. Since I'm trying to fit it on a widget-sized interface, I wanted to go with the most simplified way possible of getting content onto a remote Weblog.
But first, I needed to build the posting functionality behind the widget. So I took a quick side trip off to
AppleScript land to do a proof of concept script.
AppleScript supports XML-RPC and SOAP calls, so it's a nice tool for throwing together a simple piece of RPC functionality.
It's important to note here that AppleScript is not a direct component of the Dashboard widget architecture. Widgets are all HTML, CSS and JavaScript. But being as I'm only slightly more proficient in making RPC calls using JavaScript than I am in Swahili, I figured that I'd work toward my strengths and use folder events, AppleScript and the new Automator scripting tool in Tiger, to cheat a little. So my plan is to create a widget that writes a text file to a "buffer" folder, and then use a folder event to trigger the actual posting of the content to a Weblog.
The Blogger API calls for:
- An "appkey," which Blogger used to use as a licensing mechanism to regulate which applications could directly interface to Blogger (there's now a generic key, 0123456789ABCDEF) ;
- Your blog ID number on Blogger (the number that's part of the URL for your Web interface to a Blogger Weblogfor example, if you log into Blogger and go to create a post, and the post creation page has a URL of http://www.blogger.com/post-create.g?blogID=12345678, your blog ID number is 12345678);
- Your Blogger username;
- Your Blogger password;
- The contents of your post; and
- A boolean parameter to tell Blogger whether to publish the post right away or not.
Here's the really poorly formatted script I wrote to test the interface:
set myappkey to "0123456789ABCDEF"
set myblogid to "(the id number of your Blogger blog)"
set myusername to "your Blogger username"
set mypword to "your password"
set mypost to "This is a test blog entry using an Applescript XML-RPC call, which will be incorporated into my blogging widget."
set mypublish to true
tell application "http://plant.blogger.com/api/RPC2"
return call xmlrpc {method name:"blogger.newPost", parameters:{myappkey, myblogid, myusername, mypword, mypost, true}}
end tell
The script sends the Blogger API interface call, and returns a number that uniquely identifies the post (which is visible in the "Result" window of the AppleScript editor window).
OK, there's no error-handling yet. And the post itself, as you can see, is hardwired in the script. But it's a start, right?
This item originally appeared in Sean Gallagher's Weblog, Root Access.