1

I'm trying to find a way to create an article in a Wordpress portal using a Java application I developed. I have some clients that need to publish on this portal, but it should be something automated by this Java application. Is there any way (plugin or api) that I can send a JSON to the Wordpress portal (POST) and publish the article? I thought about creating, inside my Java application, a JSON and sending it to the Wordpress portal, something like:

{"author": "John Doe", "title": "New article", "Content": "Lorem Ipsum ...", ...}

How can I do this?

  • Sounds like you're in need of the REST API – Tom J Nowell Oct 16 '18 at 14:06
2

Yes, there is a REST API at /wp-json with core content endpoints for posts pages etc

For example, my current latest blog post:

https://tomjn.com/2018/07/23/deployment-and-wordpress/

Is available via a GET request as a JSON object at:

https://tomjn.com/wp-json/wp/v2/posts/862

And I can send a similar object via an authenticated POST request to create a new post to https://tomjn.com/wp-json/wp/v2/posts/, or a HTTP UPDATE or DELETE request.

Note that WP includes an auth method out of the box that requires a nonce and a cookie of a user capable of creating posts in order to do this. For external applications, you will need a plugin to implement OAuth1/2 or another authentication scheme of your choosing

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.