The Accidental Rubyist

invalid byte sequence in UTF-8

Using CURL to post to New Google Blogger (Gdata)

with 4 comments

I have finally got CURL to work with the new Google Beta (no longer BETA). I partly owe the problems to Google not putting up clear examples, and to a silly mistake in passing the Auth Token.

This mistake resulted in my shelving the CURL option and then writing a Java program for Listing, Posting etc (see previous post)

It then resulted in my finding a Vim-python plugin that actually works and beautifully. I also found that Google has released a Emacs plugin that uses curl. I studied it, but that did not solve my CURL script, since my script had a silly error. But from the Emacs project I have picked up an XSL that formats the feed beautifully to an HTML file.

So there was a lot of learning involved, till i found that I had grepped out the "Auth=" string from what Google returns me, but NOT removed it. It should be "auth=" in the other requests. Once that was fixed last night, all programs began running fine.

Then i brought together the various files (one for each process) and put it into one single file ( with functions, this way authenticate is coded only once. I might add that the Java API is very complicated (yuck), it is a lot slower than the CURL program. Also, it requires a lot of code, so i cannot think of combining all Java programs into one. The command line would be too complicated to handle. So i learned about bash functions, getopts (very simple, unlike Java), and various other things.

So now we have one simple file that does the following:

  • Post a given file to your new Blogger Account
  • Delete a given URI from your new Blogger Account
  • List out Titles and allow you to Delete a post based on title
  • Dump the blog feed to an XML file. I also use xsltproc and the XSL mentioned above to create an easy-to-view HTML file
  • Gives you a template for posting

Inputs: A user need only enter his Blog URL, and put his gmail account and password in a file.
All else is handled by the shell-script.I have also created Vim mappings so that the user may easily operate from within Vim. e.g.

  • bbt – inserts a new template, placing cursor in title, and highlighting CONTENT section.
  • bbp – post to Blogger
  • bbv – View last 25 titles and delete any he choses
  • bbh – help


I would like to create a program to take a file in Movable Type Format, and convert that to Gdata format and post it to Google Blogger. There are other facilities that can make this more IDE like. The posted file is returned by Google as an XML. We could use that for editing. Also, I could store the feed file-wise, or allow retrieval and let the user edit and post that.
Handling multiple blogs for one user.The source file is posted here. At present, the blogname, user and password are read from ~/.bloggerrc in the following format:

export BLOGNAME=""
export PASSWD=jklm123


Written by totalrecall

March 5, 2007 at 8:45 pm

Posted in being_geeky, Blogroll, unix

4 Responses

Subscribe to comments with RSS.

  1. Very amazing! I would like to use the script (i enjoy shell) but with the last version you require a yaml file. I follow your instructions but still have some errors because some variables are not set. What i expect to do to run your script ? thanks!


    July 10, 2008 at 12:19 am

  2. Which variables ? Pls elaborate.


    August 22, 2008 at 10:33 am

  3. Useful information. Lucky me I found your website by accident, and I’m shocked why this twist of fate didn’t happened in advance! I bookmarked it.

    tumblr brasil

    July 31, 2012 at 12:18 am

  4. Hey excellent website! Does running a blog like this take a large amount of
    work? I’ve virtually no knowledge of coding however I had been hoping to start my own blog soon. Anyways, should you have any suggestions or techniques for new blog owners please share. I understand this is off subject nevertheless I simply had to ask. Appreciate it!

    diet plans fo

    June 8, 2013 at 5:43 am

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: