Blogging APIs

On the blosxom mailing list, someone was confused about the interaction between the different APIs for accessing blogging tools and formats. They asked what the story was, and I responsed with this summary of the market (available from the blosxom mailing list archives) (which was current at the time, but getting a little dated now);

From: “Beau” <beau@d…>
Date: Tue Mar 9, 2004 4:00 pm
Subject: Re: [blosxom] APIs, new blogging things, etc.

Ok Steve, I’ll take a bash at some of this, since I’ve been working with blogging APIs for a couple years now in effect, I’ve come across all the ones that you’ve mentioned 🙂 Someone else please fill gaps or correct me if I slip up somewhere 🙂

Ok – so, in approximate chronological order of time of appearance on the scene;

* Blogger API 1.0
http://plant.blogger.com/api/
The original – based on XML-RPC [1] calls, gave access to most (all?) of Blogger’s original functionality, and was pretty darned easy to use. You POST an XML doc with encoded requests in it to a specific URL, and the response is another XML doc which you can then use however you like. Ev Williams of Blogger knocked this up over a couple of days apparently, and it went crazy from there – I’m still using it today in http://www.beaulebens.com/avantblog and it still works (usually :P)

* metaWebLogAPI
http://www.xmlrpc.com/metaWeblogApi [Added 2004-07-07]
Effectively a derivative of the Blogger API (and also XML-RPC based), this one came up to support Radio, I believe Dave Weiner knocked it up, and there was some animosity between he and Ev Williams over whether they should combine to create a unified blogging API (Radio and Blogger being the big 1 at the time) or go their separate ways. I believe one of the main reasons things went this way was because Blogger didn’t need/want title field support, but Radio did,
thus the metaWebLogAPI, intended to be more universal.

* Blogger API 2.0
http://www.blogger.com/developers/api/documentation20.html
Blogger realised that with their new versions, support from Google etc, they needed to clean up their API-act, so they started working on API 2.0. This one supports title fields and a number of other things, and is accessed via XML-RPC as well. As you can see at the URL, the draft specs were released in Feb 2003, but a couple months later, it was revoked and people were instructed not to use it, because there was no support for it and Atom (then called Echo) was going to be used in prefence… which brings us to…

* Echo… Necho… Atom API
http://www.intertwingly.net/wiki/pie/FrontPage
http://www.atomenabled.org/
Originally called Echo, then they decided that was no good, so it was refered to as Necho (Not Echo) for a while, and finally ended up being called Atom. This one is based on a REST architecture ([2], [3]), based on [4]. The Atom API sort of duplicates the efforts of RSS, in that it presents blog data in an XML format, but it also allows you to modify that data (thus API) via
REST-style interactions, involving PUT/POST/DELETE requests. I haven’t worked all this out just yet, but I have to so that I can update a few projects of mine (namely AvantBlog [5] and webpad [6]). There is also a SOAP [7] implementation of Atom, which I assume supports all the same sort of functions (retrieving posts/blogs, updating them etc), tho I haven’t looked at that at
all, as personally I hate SOAP 🙂 The idea of Atom is to provide a universal API which will be supported by all blogging systems (I believe MT and Blogger are already on board, others are likely to follow) so that we can write tools which will interop with all systems easily.

[1] http://www.xmlrpc.com/
[2] http://internet.conveyor.com/RESTwiki/moin.cgi/FrontPage
[3] http://www.xfront.com/REST.html
[4] http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm
[5] http://www.beaulebens.com/avantblog
[6] http://www.beaulebens.com/webpad
[7] http://www.w3.org/TR/soap/

Now, as for blosxom’s support for any of this mumbo jumbo – I know that sxtem [8] was written to provide Blogger API functionality for blosxom, and then you also have the atomfeed plugin [9] to provide an outgoing only (RSS-like syndication side of Atom, but not the modification side) feed for blosxom blogs. As for complete Atom API integration (allowing post editing etc via REST-calls), I’m not aware of any implementation allowing that so far, probably because the Atom spec [10] is still somewhat in flux, and even if it’s not, it’s a little hard to understand (for me at least :).

[8] http://www.blosxom.com/plugins/input/sxtem.htm
[9] http://www.blosxom.com/plugins/syndication/atomfeed.htm
[10] http://www.atomenabled.org/developers/api/atom-api-spec.php

So there you have it – as far as I am aware, that’s how the playing field lies at this point in regards to blogging APIs, and I haven’t even bothered to mention Movabletype (which, incidentally, implements a mish-mash of Blogger.com API and metaWebLogAPI functionality), so we’re doing quite well 🙂 The beauty of blosxom is that to some extent, it doesn’t even need any of this mumbo-jumbo – you can call FTP the blosxom API if you really want 🙂 When I eventually get an Atom toolkit operational, it’ll be written in PHP and linked from my Blogger API page [11], which is the current home of a number of other PHP-based blogging classes and function libraries. Until then – I’ll keep an eye out and play Lazy-web-style in the hope that someone else will beat me to it 🙂

[11] https://beaulebens.com/bloggerapi/

Cheers, and I hope that sums things up for you Steve (and others)

Beau


Beau Lebens
Information Architect
beau@d…
Dented Reality – www.beaulebens.com
Information Architecture, Usability, Web Development

Personal Information Portal

As ‘buzzword’ as that sounds, that’s basically what I’m building for myself. It’s got an integrated bookmark manager, basic email features, news aggregation, calendar, file management, plus to-do list and sticky notes (via web-form or email thanks to the power of blosxom!).

It’s framed like crazy, but will include some cool DHTML tools and things to make it easier to use and more friendly. I’m basing as much as possible on XML/XSL as well, so that is proving to be interesting. I already have a basic version of the sticky notes and to-do list features working (ugly, but operational) and that’s using XML and XSL exclusively (coming from a blosxom backend!)

I hope to build it so that it’s easy to add new tools/features into it, and that it can provide a useful point for me to start whenever I get online, since it’ll be accessible from anywhere, and have access to most things I need!.

File Append Function

Here’s a useful function that I wrote for PHP – it just opens a specified file and appends a string to it. It’s very good for logging things.

<?php
/**
 * @return boolean
 * @param $file FileNameToWriteTo
 * @param $string StringToWriteToFile
 * @desc Writes specified string to the end of the file with a linefeed attached
 */
function file_append($file, $string) {
	if (is_file($file) && is_writable($file)) {
		$fh = fopen($file, 'a');
		if ($fh) {
			fwrite($fh, $string . "\n");
			fclose($fh);
			return true;
		} else {
			return false;
		}
	} else {
		return false;
	}
}
?>

You might want to consider making the fopen() flags ‘ab’ for binary-safe (now reccommended on php.net) and also changing the ‘\n’ part to the appropriate line-endings for your operating system (\n = *NIX, \r\n = Windows, \r = Mac).

BlogLines Is Cool

Have I mentioned BlogLines.com? It really is a cool service, and what’s more – it’s free.

BlogLines is an RSS aggregator; don’t let that big name scare you – basically it allows you to get content from a bunch of sites, organised into your own directories and catgories, all in one place. It’s perfect for keeping up to date on news, reading your daily blogs, or perhaps receiving certain types of updates and things like that.

There’s not much I can say, other than it’s a very well-made system, it’s entirely web-based (so you can access it from all machines you use) and it has some great features which make managing your feed subscriptions really easy. Check it out and see what I’m talking about.

Settling In At DreamHost

Well, things aren’t going too badly with DreamHost, I’m sorting out all my domains and CGI, databases, PHP etc and things are looking good. When I get beaulebens.com across, then I will know things are good 🙂

UPDATE: Things are looking very good – .com.au is transferred properly and appears to have propagated pretty much everywhere, judging by the traffic on my old account. I’ll leave it there for a couple days longer and make sure I’ve migrated everything properly, then close my account at phpwebhosting.com.

New Web Host Soon

Well, I think I’ve finally outgrown phpwebhosting.com as my host, so I’ve started the process of setting up my new account with DreamHost.com.

The reasons that I have decided on DreamHost are along these lines:

  • UNIX Servers (personal requirement)
  • SSH/Shell Access (crucial)
  • .htaccess Editing (crucial)
  • CGI/PHP (crucial)
  • Ability to host multiple domains/subdomains (can only have 1 domain on phpwebhosting)
  • IMAP Mail server – good benefit, since I am switching to web-based mail
  • Good price – for me to host 10 domains there (6 properly + 4 mirroring) is $14.95 per month
  • Good reputation – checked around and only heard good things. The usual criticism of their support, but hopefully I won’t be using it much, so it won’t matter 🙂
  • FTP – I can add users who will have FTP access to certain areas on my servers, which will be good for sharing some space with friends
  • crontabs – can edit them and set them when I want

So please bear with me over the next few days as things might get a little messy on this site (and related ones) while I am moving things around between this host and my new one.

Useful JavaScript Snippet

One of the coolest things in the PHP programming language is its excellent handling of arrays. The same, sadly, cannot be said for JavaScript 🙂

This small JavaScript function implements one of the cool functions available in PHP, making it easier to store things in an array, and then check to see if they’re in there later.

// Returns true or false based on whether the specified string is found
// in the array. This is based on the PHP function of the same name.
// Written by Beau Lebens
function in_array(stringToSearch, arrayToSearch) {
	for (s = 0; s < arrayToSearch.length; s++) {
		thisEntry = arrayToSearch[s].toString();
		if (thisEntry == stringToSearch) {
			return true;
		}
	}
	return false;
}

blosxxxom – it’s not porn

In amongst all the talk of the Atom API (which might one day actually be released and usable) and RSS, and with me working on some XML/XSL things at work, I realised that there’s probably another option entirely with blosxom as far as templates/flavours/themes goes, and it goes a little something like this;

Three Xs, therefore blosxxxom, that’s one for blosxom (Apple’s OSX), one for XML and one for XSL, which are the three technologies we’re dealing with here.

  1. Install the theme plugin for blosxom and get it working (this plugin makes life much easier!)
  2. Now create a new theme, with a suitable name (mine’s called ‘blosxxxom’ for the sake of the experiment, and it looks like this; page.blosxxxom. This theme should create a valid XML document from your posts.
  3. Your XML output should refer to an XSL stylesheet, which will actually take care of doing the formatting, entirely client-side (style.xsl in my example theme file)
  4. In the XSL file, just use normal XSL processing instructions to handle the output and presentation of the XML document into XHTML!
  5. Point your browser to blosxom and tell it to use the flavour name that you used to create this theme, and you should be able to see what the output looks like. View the source of the document and you should see the plain XML produced by blosxom 🙂

Now, for a couple notes;

  • I made my content_type value in the theme text/xml, but this forced blosxom to encode special characters to be nice for me. I found that it was better to comment this section of the main CGI out so that I could drop the values in, and wrap them in the CDATA tag seen in the XML theme.
  • Rather than worry about what’s in the body much, I just wrapped things in a <![CDATA[ tag ]]> to be safe.
  • Mozilla doesn’t currently display my output properly – it’s not doing links (or any tags) properly, and it’s just showing them rather than interpreting them as HTML. Anyone got any ideas on this one?
  • There’s more to be done, but it’s a fun point to start at, and there’s no reason why you can’t add things like a COMMENTS element to your STORY node, or a KARMA, a META node with a series of elements – it’s pretty free-form if you’re only doing the XML for your own presentation needs!

Hope that’s inspired some people to try some things out that they might not have otherwise tried, and if nothing else, it just demonstrates how flexible blosxom really is! 🙂

Resizable Google

I don’t know if anyone else noticed, or indeed when it actually happened, but I know that a couple months ago, you couldn’t successfully resize the Google results pages using the ‘Text Size’ option in Internet Explorer.

Purely by accident, I opened a Google page with my text size set to ‘largest’ and lo and behold, they have modified their HTML to allow for resizing of fonts. Even their AdWords ads resize according to the browser preference.

Looking at the source, it looks like they are slowly moving towards a CSS-based layout/design, although they still have a ways to go. Incidentally, I did a copy of their layout with CSS for an internal search engine that I built and it wasn’t that hard at all, their design even lends itself to being done with DIVs, UL/LIs and A tags, styled up with CSS.

So here’s their style definition on a results page now-days;

body,td,div,.p,a{font-family:arial,sans-serif } 
div,td{color:#000} 
.f,.fl:link{color:#6f6f6f} 
a:link,.w,a.w:link,.w a:link{color:#00c} 
a:visited,.fl:visited{color:#551a8b} 
a:active,.fl:active{color:#f00} 
.t a:link,.t a:active,.t a:visited,.t{color:#ffffff} 
.t{background-color:#3366cc} 
.h{color:#3366cc} 
.i,.i:link{color:#a90a08} 
.a,.a:link{color:#008000} 
.z{display:none} 
div.n {margin-top: 1ex} 
.n a{font-size:10pt; color:#000} 
.n .i{font-size:10pt; font-weight:bold} 
.q a:visited,.q a:link,.q a:active,.q {color: #00c; text-decoration: none;} 
.b{font-size: 12pt; color:#00c; font-weight:bold} 
.ch{cursor:pointer;cursor:hand} 
.e{margin-top: .75em; margin-bottom: .75em} 
.g{margin-top: 1em; margin-bottom: 1em}

As you can see, they are not defining a font size for a lot of their elements, which is a good move, as it will inherit the browser settings automatically. One thing that I did notice is that the fixed-size fonts they are using (“.n a” and “.n .i”) are only applied to the numbers used for the links to different pages of results. I am assuming that they have done this because otherwise there’s the potential that thei cool little string of ‘o’s will be messed up from font sizing 🙂

Good Work Google! Good to see more of the big-boys embracing CSS design, I just hope that they continue down this path and have a completely CSS-driven design in the near future, browsers are almost up to speed so that it’s a valid move for them I think.