[wp-hackers] making new post using cURL

Chris Jean gaarai at gaarai.com
Wed Nov 4 03:49:49 UTC 2009


I don't believe that it is possible to do what you want in the method 
that you are attempting. The nonces will defeat you, and if they don't 
immediately, they will render your script useless within a short period 
of time. In addition, this is just working too hard to do something that 
already has a simple to use interface.

You should look in the XMLRPC functionality of sending data to 
WordPress. There's a good rundown of this method at the following link:

http://www.nickycakes.com/post-to-wordpress-remotely-with-xmlrpc-in-php/

You could easily wrap this into a small PHP script that you could call 
from the command line.

Chris Jean
http://gaarai.com/
http://wp-roadmap.com/



Chris Dawson wrote:
> 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
>
>
>   


More information about the wp-hackers mailing list