roller-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Levine <levine_br...@hotmail.com>
Subject RE: Programmatic blog entries
Date Wed, 19 Mar 2008 17:16:41 GMT


Just in case any one else is interested in this, here's what I've found out:

As Finbar suggested, go here:
https://blogapps.dev.java.net/java/blogapps_2.x/README.html

>From there you can download the src for the BlogPoster, along with some other projects.

The BlogPoster is one java file and one config file.  I ended it up rewriting it for my own
needs and pulled it into my project.  

You'll need these jars to compile/run the example (they are included in the download, you
just have to add them to your classpath):
xmlrpc-common-3.0.jar
xmlrpc-client-3.0.jar
ws-commons-util-1.0.1.jar

The code that does the work is this:
       client.execute ( "metaWeblog.editPost",
            new Object[] { postId, userName, password, post, Boolean.TRUE } ) ;

The example shows you how you can create a new post with a title, description, and the creation
date.  The guts of the post is a Hashtable called post.  The boolean value at the end is a
publish flag.  If you set it to Boolean.FALSE it will save the entry as a draft, rather than
a published entry.

One thing I thought was a bit weird was that the "description" was actually the body of the
blog entry.  I couldn't find a way to set the summary.
You can also set multiple categories by creating a Vector<String> and putting the category
names in there.  Then I added the vector to the post Hashtable with the key "categories"

If you set the date for the time in the future, it will schedule publishing time for that
entry.

You can also edit a post by changing the first argument in this code:
Integer result = (Integer) client.execute("metaWeblog.newPost",

to this :
    "metaWeblog.editPost"

and also change the blogId (the handle for your blog) to the postId, a very long string that
looks like this -- 1ab7c416-1231-42eb-a4e8-2g323e67bf30
When you create a blog entry, using this API, it returns that string, so I save it away in
a DB for future editing

There are also ways to get the available categories, get recent posts, and a add a media object.
 I didn't experiment with those.

Hope this is helpful to someone.  Feel free to email me if you have any questions.

/B

> Date: Mon, 17 Mar 2008 20:46:14 +0100
> To: user@roller.apache.org
> Subject: Re: Programmatic blog entries
> From: elevenit@gmail.com
> 
> Brian,
> 
> There is a lot of useful code over at the Blogapps site (an off shoot of 
> the book 'RSS and Atom In Action' by Dave Johnson):
> https://blogapps.dev.java.net/java/blogapps_2.x/README.html
> 
> One of these is a blog poster:
> Blogposter simple XML-RPC example
> 
> Roller supports the Blogger API so any client that understands this is fine.
> 
> 
> Name: Finbar Dineen
> Web: http://www.limlom.com/
> 
> 
> Brian Levine wrote:
> > 
> > Hi, I'm just getting started using Roller 4.  As part of my blog, I'd like to be
able to add blog entries programmatically.  So, instead of using the HTML authoring form and
manually typing in a blog entry, I'd like to be able to run my java program to create the
HTML and then stick that HTML into a blog post.
> > 
> > I've already written the part that generates the HTML, so I'd like to know if creating
and editing blog entries is possible without using the HTML editor.
> > 
> > 
> > Thanks!
> > /Brian
> > 
> > _________________________________________________________________
> > Climb to the top of the charts! Play the word scramble challenge with star power.
> > http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_jan

_________________________________________________________________
Shed those extra pounds with MSN and The Biggest Loser!
http://biggestloser.msn.com/
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message