tonybaldwin's posterous

« Back to blog
 

This is just another test...

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:

#!/bin/bash

# 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.

username=YOUR_USERNAME
password=YOUR_PASSWORD
apitok=YOUR_API_TOKEN

# 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" http://posterous.com/api/2/sites/1814977/posts | grep error) ]]; then
        echo "Too bad, do0d...FAIL!"
else
        echo "Success!  Posted to Posterous!"
fi

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

exit

If you are seeing this post, then, I was successful, which means I have conquered the posterous API (with John's help) sufficiently that I should now be able to add posterous support to Xpostulate, my xposting blog+microblog+friendika client in tcl/tk. :D ./tony

Posted
Posterous theme by Cory Watilo.