Archive for August 7th, 2007


7Aug2007

In the first part of this series titled “Would You Like To Post To WordPress From Java?” I introduced you (hopefully) to the XML-RPC mechanism that WordPress implements. I also showed how it is quite simple to post to a WordPress blog using Java and the Redstone XML-RPC API. In this installation I’d like to expand the example a bit further.

First, however I’d like to apologize for posting non-working code. :( I posted the example without actually compiling and/or testing it. If you downloaded and fixed the errors to get it to compile you also probably noticed that the method would not successfully login to your blog. Doh! I’ll be fixing those errors in the next version of the file, so hopefully you will walk away with something you can actually modify to your liking… and use.

Now, how about that last example? Did you notice anything lacking in the data that we posted. If you recall the method signature looks like this: blogger.newPost(blog_ID, user_login, user_pass, content, publish)
This is actually part of the problem with the first implementation. Looking into the xmlrpc.php file, the method starts looking for the blog_ID at array index 1… not zero. So the method signature should actually be like this: blogger.newPost(emptyData, blog_ID, user_login, user_pass, content, publish)
I’m not sure what emptyData is supposed to be or even why it is there, but I just posted an empty string here and everything was great. The method doesn’t actually ever use that argument… odd.

Ok, back to the initial question… do you notice anything lacking? Sure, a lot of things are missing. Mainly and most blaring is the lack of a title. In the above and previous example all we are posting is the content. That’s no good. I would like to at a minimum be able to specify the title of my post. For that we will take advantage of the metaWeblog API calls. There is a similar function with the following signature:

metaWeblog.newPost(blog_ID, user_login, user_pass, content_struct, publish)

First, this method does NOT contain the empty data argument. Secondly you’ll notice that instead of passing a string for content, we are passing a struct. So what type of data might this struct contain? It contains: title, link, description, author, category, comments, enclosure, guid, pubDate and source. Wow, that’s a lot more information! I won’t be covering all of these different data elements, but you can read more about them on the RSS 2.0 Specification on the Harvard Law IT Page. There are actually a few more elements than listed here which we will make use of in an upcoming post. :) For now, however I am content to just have the title.

We’ll need to change the method we are calling:

      // XML-RPC method
      String sXmlRpcMethod = "metaWeblog.newPost";




7Aug2007

Through the course of some research for a project I ran across a CGI directory site. Basically it lists various CGI scripts and also a handful of tutorials and tips. The site is http://www.cgi-bin.com. What is so special about this directory? Well, nothing actually. I just thought I’d mention it for the following funny reason. Browsing through the directory I found an interesting script that I wanted to take a look at. I clicked through to the details screen, which had a description of various properties of the script (platform, cost, author, etc). My next logical step was to click through to the site owner so that I could download the script. No such luck!

The site uses a “jump” CGI script to redirect you to the destination of the script. Unfortunately clicking on the link gives you an Error 404 - File Not Found. Not the script you are looking for… the redirect script. Anyway, I just thought it somewhat ironic that a “CGI” directory had a broken CGI script as it’s main mechanism of getting to the content of the site.




ss_blog_claim=facbfc3e9df91e94d4fa0f8d5232bc28