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="http://www.w3.org/2005/Atom">
  <title type="text">Knock knock</title>
  <content type="xhtml">
    <div xmlns="http://www.w3.org/1999/xhtml">
      <p>Who's there?</p>
      <p>Orange.</p>
      <p>Orange who?</p>
      <p>Orange you glad you know how to post using curl?!? (lol!)</p>
    </div>
  </content>
  <category scheme="http://www.blogger.com/atom/ns#" term="joke"/>
  <category scheme="http://www.blogger.com/atom/ns#" term="curl"/>
</entry>
With the above stored in blog_post.xml, we can now post it using the following shell script:
#!/bin/sh

# Authenticate
# Requires $GDATA_PASSWORD to be set as an environment variable.
G_AUTH_TOKEN=`curl 2>/dev/null https://www.google.com/accounts/ClientLogin \
    -d Email=YOUR_EMAIL_ADDRESS@example.com \
    -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" \
    "http://www.blogger.com/feeds/YOUR_BLOGS_ID/posts/default" --data "@blog_post.xml"

11 comments:

Anonymous said...

Seems the end quote is missing.

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

Fredy said...

Cool!!!
That's what I was looking for.

Atrus 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?

otr said...

VIRUS REMOVAL

Is Your Computer Sluggish or Plagued With a Virus? – If So you Need Online Tech Repairs
As a leader in online computer repair, Online Tech Repairs Inc has the experience to deliver professional system optimization and virus removal.Headquartered in Great Neck, New York our certified technicians have been providing online computer repair and virus removal for customers around the world since 2004.
Our three step system is easy to use; and provides you a safe, unobtrusive, and cost effective alternative to your computer service needs. By using state-of-the-art technology our computer experts can diagnose, and repair your computer system through the internet, no matter where you are.
Our technician will guide you through the installation of Online Tech Repair Inc secure software. This software allows your dedicated computer expert to see and operate your computer just as if he was in the room with you. That means you don't have to unplug everything and bring it to our shop, or have a stranger tramping through your home.
From our remote location the Online Tech Repairs.com expert can handle any computer issue you want addressed, like:
• - System Optimization
• - How it works Software Installations or Upgrades
• - How it works Virus Removal
• - How it works Home Network Set-ups
Just to name a few.
If you are unsure of what the problem may be, that is okay. We can run a complete diagnostic on your system and fix the problems we encounter. When we are done our software is removed; leaving you with a safe, secure and properly functioning system. The whole process usually takes less than an hour. You probably couldn't even get your computer to your local repair shop that fast!
Call us now for a FREE COMPUTER DIAGONISTIC using DISCOUNT CODE (otr214428@gmail.com) on +1-914-613-3786 or chat with us on www.onlinetechrepairs.com.

otr said...

1 Problem: HP Printer not connecting to my laptop.

I had an issue while connecting my 2 year old HP printer to my brother's laptop that I had borrowed for starting my own business. I used a quick google search to fix the problem but that did not help me.
I then decided to get professional help to solve my problem. After having received many quotations from various companies, i decided to go ahead with Online Tech Repair (www.onlinetechrepairs.com).
Reasons I chose them over the others:
1) They were extremely friendly and patient with me during my initial discussions and responded promptly to my request.
2) Their prices were extremely reasonable.
3) They were ready and willing to walk me through the entire process step by step and were on call with me till i got it fixed.
How did they do it
1) They first asked me to state my problem clearly and asked me a few questions. This was done to detect any physical connectivity issues with the printer.
2) After having answered this, they confirmed that the printer and the laptop were functioning correctly.
3) They then, asked me if they could access my laptop remotely to troubleshoot the problem and fix it. I agreed.
4) One of the tech support executives accessed my laptop and started troubleshooting.
5) I sat back and watched as the tech support executive was navigating my laptop to spot the issue. The issue was fixed.
6) I was told that it was due to an older version of the driver that had been installed.

My Experience
I loved the entire friendly conversation that took place with them. They understood my needs clearly and acted upon the solution immediately. Being a technical noob, i sometimes find it difficult to communicate with tech support teams. It was a very different experience with the guys at Online Tech Repairs. You can check out their website www.onlinetechrepairs.com or call them on 1-914-613-3786.
Would definitely recommend this service to anyone who needs help fixing their computers.
Thanks a ton guys. Great Job....!!

Unknown said...

Awesome article Lot's of data to Read...Great Man Keep Posting and redesign to People..Thanks www.ansonpc.com

Alex moner said...

Your site is very informative and your articles are wonderful.laptop repair nottingham

pitbull said...

Your work is totally appreciative and informative. best wordpress themes

Elizabeth J. Neal said...

Super site! I am Loving it!! Will return once more, Im taking your food likewise, Thanks.
technology

John Fei said...

An ai site that writes essays for you is a remarkable tool in the digital age. With its advanced algorithms and natural language processing capabilities, it can generate well-crafted essays tailored to your needs. This innovative technology saves time and provides valuable assistance to students and professionals seeking quality written content. The convenience and reliability of an AI site that writes essays make it an indispensable resource for those looking to excel in their academic or professional pursuits.