[wp-hackers] making new post using cURL
Chris Dawson
xrdawson at gmail.com
Wed Nov 4 08:19:52 UTC 2009
Chris,
Thanks for the response.
I have looked at and successfully made a post using the XML-RPC feature of
Wordpress. However, the reason this did not work for me is that I need to
add a parameter to the post for a plugin (specifically the Blubrry
Powerpress plugin). I don't believe there is a way to add data for use by a
plugin using the XML-RPC call, right? I tried adding the parameter I
needed, and it did not work, so I assume the XML-RPC call has a limited set
of parameters it will accept.
I've looked at this from various ways, implementing a hook inside my own
plugin to do something when a new post is created using add_filter, etc.
The problem is that the Powerpress plugin is pretty hairy and I have no
clear idea after looking through the source what the process is to create an
enclosure and which functions to call. The easiest thing, in my mind, was
to make a post using cURL with this parameter passed in
"Powerpress[podcast][url]=someUrlToAnMp3". That is what the Wordpress page
looks for and the Powerpress plugin does the right thing when something is
posted in that format.
I'm not opposed to doing it another way, but this is my dilemma. Any ideas?
Thanks,
Chris
> 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/
>
>
On Tue, Nov 3, 2009 at 6:58 PM, Chris Dawson <xrdawson at gmail.com> 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
>
>
> --
> Chris Dawson
> 971-533-8335
>
>
--
Chris Dawson
971-533-8335
More information about the wp-hackers
mailing list