Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a post to wordpress using the api?

How can I remotely make a post to a user's blog after he/she gives me his login info using the wordpress api? What method do i need to use, what paremeters should it have, etc? Sample code will be great.

I'd prefer to use the XML-RPC api but others will also be acceptable.

like image 888
Ali Avatar asked Jan 24 '10 06:01

Ali


People also ask

Is there an API for WordPress?

WordPress already has multiple APIs, for things like plugins, settings, and shortcodes. These can be used by plugin and theme developers to interact with WordPress core and make things happen (like creating shortcodes and adding settings screens to the WordPress admin).

How do I post to REST API?

To post JSON to a REST API endpoint, you must send an HTTP POST request to the REST API server and provide JSON data in the body of the POST message. You also need to specify the data type in the body of the POST message using the Content-Type: application/json request header.


2 Answers

yeah you can use metaWeblog.newPost or blogger.newPost, an example of the first:

http://www.wprecipes.com/post-on-your-wordpress-blog-using-php

uses curl and xmlrpc_encode_request

an example of the second:

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

yeah and @Francis is correct

like image 178
jspcal Avatar answered Oct 19 '22 22:10

jspcal


I personally use the JSON API plugin. Create a post using:

http://www.example.com/api/create_post/?nonce=123456789&title=My%20Post&status=publish
like image 22
Sean H Avatar answered Oct 20 '22 00:10

Sean H