如何访问 WordPress.com 站点的 WP REST API? [英] How to access WP REST API for WordPress.com sites?

查看:38
本文介绍了如何访问 WordPress.com 站点的 WP REST API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到 WordPress.com 最近开始使用 Gutenberg,它依赖于 WP REST API.我正在构建一个插件,我想使用来自自托管站点的 WP REST API,并让它与 WordPress.com 站点通信,但我无法找到 REST API 基本 URL.例如,https://cmljnelson.wordpress.com/wp-json 是 404.

进一步阅读:

I see WordPress.com recently started using Gutenberg, which relies on the WP REST API. 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. 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. How can I find the WP REST API base URL for WordPress.com sites?

解决方案

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/.

If you want access to the REST routes of a specific site in WordPress.com, use the /sites route:

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

Further reading:

这篇关于如何访问 WordPress.com 站点的 WP REST API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆