简体   繁体   English

如何访问WordPress.com网站的WP REST API?

[英]How to access WP REST API for WordPress.com sites?

I see WordPress.com recently started using Gutenberg, which relies on the WP REST API. 我看到WordPress.com最近开始使用依赖WP REST API的Gutenberg。 I'm building a plugin and I'd like to use the WP REST API from a self-hosted site, and have it communicate with a WordPress.com site, but I'm having trouble finding the REST API base URL. 我正在构建一个插件,我想从一个自托管网站使用WP REST API,并使其与WordPress.com网站进行通信,但是我很难找到REST API基本URL。 For example, https://cmljnelson.wordpress.com/wp-json is a 404. The documentation about REST API discovery doesn't seem to apply to WordPress.com. 例如, https://cmljnelson.wordpress.com/wp-json ://cmljnelson.wordpress.com/wp-json是404。 有关REST API发现的文档似乎不适用于WordPress.com。 How can I find the WP REST API base URL for WordPress.com sites? 如何找到WordPress.com网站的WP REST API基本URL?

WordPress.com's REST API apparently is shared among sites hosted there and you can access it here: https://public-api.wordpress.com/wp/v2/ . WordPress.com的REST API显然是在托管于此的站点之间共享的,您可以在这里访问它: https : //public-api.wordpress.com/wp/v2/

If you want access to the REST routes of a specific site in WordPress.com, use the /sites route: 如果要访问WordPress.com中特定站点的REST路由,请使用/sites路由:

https://public-api.wordpress.com/wp/v2/sites/{site-id or domain}/

WordPress.com REST API

Further reading: 进一步阅读:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM