Post on Blogger using curl

This command line curl script reads an XML file containing the blog post's XML and uses curl to authenticate and post to Blogger. Here is the XML for an example post:
<entry xmlns="">
  <title type="text">Knock knock</title>
  <content type="xhtml">
    <div xmlns="">
      <p>Who's there?</p>
      <p>Orange who?</p>
      <p>Orange you glad you know how to post using curl?!? (lol!)</p>
  <category scheme="" term="joke"/>
  <category scheme="" term="curl"/>
With the above stored in blog_post.xml, we can now post it using the following shell script:

# Authenticate
# Requires $GDATA_PASSWORD to be set as an environment variable.
G_AUTH_TOKEN=`curl 2>/dev/null \
    -d \
    -d Passwd=$GDATA_PASSWORD  \
    -d accountType=GOOGLE \
    -d source=curlExample \
    -d service=blogger \
  | grep '^Auth=' | cut -c 6-`

# Post on my blog.
curl -v --request POST -H "Content-Type: application/atom+xml" \
    -H "Authorization: GoogleLogin auth=$G_AUTH_TOKEN" \
    "" --data "@blog_post.xml"


weakish said...

Seems the end quote is missing.

It should be --data "@post.xml".

Fredy said...

That's what I was looking for.

Linuxbyexamples said...

How can I use this method to make a post-draft instead of puslished-post ? I mean when running this script it make post publish immediately, but I want to make it draft first.

Another question, How can I include meta tag description (Search Description) in this .xml file ?

العمدة said...

thanks, it works
can it work with php Curl?
what changes are needed?