我可以将REST API用于WordPress.com上托管的网站吗 [英] Can I use the REST API for a site hosted on WordPress.com
问题描述
我在WordPress.com上托管了一个博客.当我尝试发出GET
请求以检索帖子时,我得到了一个未找到"的html页面.
I have a blog hosted on WordPress.com. When I try to make a GET
request to retrieve the posts I get a 'Not Found' html page.
https://alexkojin.wordpress.com/wp-json/wp /v2/posts
我了解旧版公共API ,但是它不允许我检索私人帖子.
I know about the legacy public API but it doesn't allow me to retrieve private posts.
我可以将REST API用于WordPress.com上托管的网站吗?
Can I use the REST API for site hosted on WordPress.com?
推荐答案
在WordPress.com平台上,REST API实际上是在
On the WordPress.com platform the REST API is actually hosted and structured at https://public-api.wordpress.com/wp/v2 for all sites. In addition, there's a /sites/
endpoint that will namespace your specific site.
例如,您的网站的根端点将是 https://public-api.wordpress.com/wp/v2/sites/alexkojin.wordpress.com/.其他端点的行为与在自托管平台上的行为相同.
For example, the root endpoint for your site would be https://public-api.wordpress.com/wp/v2/sites/alexkojin.wordpress.com/. The other endpoints behave the same way as they would on a self hosted platform.
例如,您的页面可以在 https下找到://public-api.wordpress.com/wp/v2/sites/alexkojin.wordpress.com/pages
For example, your pages would be found under https://public-api.wordpress.com/wp/v2/sites/alexkojin.wordpress.com/pages
您可以在 https中找到更多信息. ://developer.wordpress.com/2016/11/11/wordpress-rest-api-on-wordpress-com/,包括如何设置OAuth2(访问私人帖子将需要此权限).
You can find more information at https://developer.wordpress.com/2016/11/11/wordpress-rest-api-on-wordpress-com/ including how to setup OAuth2 (which will be required to access private posts).
这篇关于我可以将REST API用于WordPress.com上托管的网站吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!