生成从WordPress博客获取数据的API URL的方法

huangapple go评论63阅读模式
英文:

How to generate an API url to get data from WordPress blog

问题

目前,我想从我的WordPress个人博客获取数据,以在我的个人网站上使用。我尝试使用以下URL:https://shopssam.wordpress.com/wp/v2/posts,但它不起作用。经过一段时间的研究,必须对**永久链接(PermaLinks)**进行更多调整。而且我在WordPress首页设置中找不到它。

英文:

Currently, I want to get data from my personal blog on WordPress to put through my personal website. I tried using this URL: https://shopssam.wordpress.com/wp/v2/posts and it didn't work. After a while of researching, there must be more tweaks in PermaLinks. And I can't find it anywhere in the WordPress home page settings.

答案1

得分: 2

wordpress.com 使用与正常的 wordpress.org 不同的 REST API。

首先从下面的链接中找到您的站点ID:
https://dashboard.wordpress.com/wp-admin/index.php?page=my-blogs

然后将下面参数中的 SITEID 替换为您的站点ID,以获取所有文章:
https://public-api.wordpress.com/rest/v1/sites/{YOUR_SITE_ID_GOES_HERE}/posts

英文:

wordpress.com use different REST API than normal wordpress.org.

First find your Site ID from link bellow:
https://dashboard.wordpress.com/wp-admin/index.php?page=my-blogs

Then replace SITEID in below parameter to get all posts:
https://public-api.wordpress.com/rest/v1/sites/{YOUR_SITE_ID_GOES_HERE}/posts

答案2

得分: 1

以下是翻译好的部分:

对于那些需要更清晰答案的人,您可以在这里阅读信息:https://developer.wordpress.com/docs/api/。这是WordPress.com的文档,请注意在使用WordPress时要小心,因为尽管具有相同的名称,WordPress.comWordPress.org的工作方式完全不同。这是我修改以获取数据的确切API URL:https://public-api.wordpress.com/rest/v1/sites/shopssam.wordpress.com/posts

其中shopssam.wordpress.com是我的博客URL。

英文:

For those who need a clearer answer. You can read the information here: https://developer.wordpress.com/docs/api/. This is a document for WordPress.com, be careful when using WordPress, because despite having the same name, WordPress.com and WordPress.org have completely different ways of working. And here is the exact API URL that I modified to get the data: https://public-api.wordpress.com/rest/v1/sites/shopssam.wordpress.com/posts

Which shopssam.wordpress.com is my blog URL.

huangapple
  • 本文由 发表于 2023年6月11日 20:35:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/76450502.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定