最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

posts - Create an article from another Java application

programmeradmin1浏览0评论

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?

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?

Share Improve this question asked Oct 16, 2018 at 14:02 aseolinaseolin 1132 bronze badges 1
  • Sounds like you're in need of the REST API – Tom J Nowell Commented Oct 16, 2018 at 14:06
Add a comment  | 

2 Answers 2

Reset to default 3

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/2018/07/23/deployment-and-wordpress/

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

https://tomjn/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/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

I think you're asking about WordPress REST API. From The Handbook:

The WordPress REST API provides an interface for applications to interact with your WordPress site by sending and receiving data as JSON (JavaScript Object Notation) objects. It is the foundation of the WordPress Block Editor, and can likewise enable your theme, plugin or custom application to present new, powerful interfaces for managing and publishing your site content.

The linked documentation above should have all the resources you need to build something like what you're looking for.

发布评论

评论列表(0)

  1. 暂无评论