This post originated from an RSS feed registered with Java Buzz
by Russell Beattie.
Original Post: The Weblog APIs in a single JSP
Feed Title: Russell Beattie Notebook
Feed URL: http://www.russellbeattie.com/notebook/rss.jsp?q=java,code,mobile
Feed Description: My online notebook with thoughts, comments, links and more.
I should be in bed, but I'm still awake messing around with weblog tech. I've been meaning to get around to implementing the Blogger, MetaWeblog, and MoveableType XML-RPC APIs for a while now (think: 2 years) but I just never bothered. Well, that's not true, I'd take a look at it, wonder what the hell a struct was in Java and move on. But now that I'm trying to meet all the criteria on this Blog Feature List both personally and professionally, I figured I'd better sit down for a moment and work it out.
XML-RPC, as most people have pointed out before, isn't particularly hard to get working. The problem is that what is affectionately called the Weblog APIs by some are actually several different groups of methods spread between their respective websites. Though MoveableType does have a nice summary, you still have to go track down and grok the original sources. Then, if you want to get this stuff running in Java, you have to contend with the horrendous samples that most Java programmers out there have created. I grabbed Blojsom, Roller and Pebble's implementations and was completely astounded by their complexity. Simon's is the clearest - and was a great starting point for me, but still. Why do Java programmers have to make this stuff so damn hard?!?!
So here's a single JSP page with an empty framework which supports of all three Weblog APIs.
That's just the original Blogger 1.0 API. The rest of doc has the other method signatures. To use this file, go get Apache's XML-RPC Jar, throw it into your WEB-INF/lib, upload the .jsp file to your server as the endpoint and you'll have a basis to start working with editors like w.bloggar, Zempt and blogBuddy. Easy.
All the JSP does right now is just allow you to connect with those clients and log the methods being called. It's sort of like a JSP based base-class for you to fill in with your own method implementations. But that should be a good enough starting point for most projects. I wish I had this myself. For my personal weblog, I have to now go through and add the SQL queries to validate the user, query posts and update tables, but that's just busy work really. I think it would be really cool if someone just took this JSP as a starting point and instead of filling in the details with SQL stuff, wrote out actual .html files instead, creating a one page XML-RPC based weblog engine. Wouldn't that rock? I wish I had extra minutes to do it myself.
I find it very strange that there isn't a Java example out there like this already. Is there and I missed it?
The one thing that I don't really understand is what exactly the Blogger API has implemented. If you go to the offical Blogger 1.0 API page, it only lists six methods. But w.bloggar expects at least another few methods like getRecentPosts() (but not the metaWeblog version, a different one) that are also mysteriously documented on the MoveableType API page. It's strange. Then there's the Blogger 2.0 API which has been abandoned, but is floating out there, which doesn't match the signatures either. The metaWeblog API is a pretty straight forward addition to the Blogger stuff (if sketchily documented) as is MoveableType's. But in general it's just chaos out there. At the bare minimum someone should create a JavaDoc-like page explaining all these methods. No wonder the Atom guys wanted to organize all this.
Anyways, next up will actually be the AtomAPI after I get the XML-RPC methods implemented (I'll update the linked sample page as I go along)... I will definitely need to sleep before I tackle Atom, and may need healthy amounts of alcohol too.