tonybaldwin | blog

non compos mentis

Posting to Posterous with curl

leave a comment »

Okay, so I DID successfully post with curl (thanks to some clarifications frmo John Tucker). Now, I have written a script that will allow me to write a post in vim and fire it off. It looks like this:

# post to posterous from bash cli with curl 

# I could do this with read -p "Enter ur username d0od: " username 
# kind of thing, but I just hardwired my info in. 
# edit accordingly for your info. 

# creates a date stamp for naming the post file 
filedate=$(date %m%d%y%H%M%S) 

# set 
post title read -p "Enter a post title: " ptitle 

# write post in vim 
vim $filedate.ppost pbody="$(cat $filedate.ppost)" 

# send post to posterous with curl 

if [[ $(curl -X POST -u $username:$password -d "api_token=$apitok" \
-d "post[title]=$ptitle" -d "post[body]=$pbody" \ | grep error) ]]; then 
echo "Too bad, do0d...FAIL!" 
echo "Success! Posted to Posterous!" 

mv $(pwd)/$filedate.ppost ~/Documents/fposts/ 
# moved post to dir for safekeeping. 
# you can use different dir, d00d 


This means that I have consquered the posterous API, and will now be able to add posterous support to Xpostulate.

Written by tonybaldwin

September 19, 2011 at 6:48 pm

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: