[wp-hackers] making new post using cURL

Chris Dawson xrdawson at gmail.com
Wed Nov 4 02:58:11 UTC 2009


I'm trying to make a new post into Wordpress using the command line cURL
tool.  I've looked at the source of the post-new.php page to see the
variables listed and have sniffed the request when I make a post in Firefox
using Firebug.  However, there are a bunch of parameters and I cannot figure
out which are required and which are not, and I'd like to make my request as
slim as possible.  Does anyone have a working example of how to do this, or
know which parameters are required in the request?  I'm also confused if the
_wpnonce is necessary.

This is what I have so far, which successfully logs in and stores the auth
cookie, but the rest of the request fails.

#!/bin/sh


url="http://mywordpressurl.com"
login_url="$url/wp-login.php"
new_post_url='$url/wp-admin/post-new.php'
name="foobar"
pwd='barfoo'
button='wp-submit'
cookies="cookies.txt"


create_post () {
    curl -s -L -c $cookies -d "pwd=$pwd" -d "log=$name" -d
"wp-submit=Log%20In" "$login_url"
    curl -s -b $cookies -d "post_type=post" -d 'post_title=Hey there' -d
'content=Yeah, this is a new post' "$new_post_url"
}

create_post


-- 
Chris Dawson
971-533-8335


More information about the wp-hackers mailing list