是否有用于从您的站点创建 API 的 wordpress 插件? [英] Is there a wordpress plugin for creating an API from your site?

查看:21
本文介绍了是否有用于从您的站点创建 API 的 wordpress 插件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以 API 形式使用来自我的 wordpress 站点的数据.也许 REST 带有 JSON 输出.我想知道是否有任何插件可以自动使 wordpress 数据可以从其运行的站点外部访问,类似于大多数 Web API 的工作方式.

I'd like to use the data from my wordpress site in an API form. Maybe REST with JSON output. I'm wondering if there's any plugins that automatically make the wordpress data accessible from outside the site its running on, similar to the way most web APIs work.

推荐答案

WordPress 基本上是一个基于 REST 的平台.您输入带有特定查询字符串的 URL(有时隐藏在漂亮的永久链接"中),系统会根据您的主题中定义的布局和结构返回半静态资源.

WordPress is basically a REST-powered platform to begin with. You enter a URL with a particular query string (sometimes buried in a 'pretty permalink') and the system returns a semi-static resource based on the layout and structure defined in your theme.

要将其构建为API",您首先需要确定要返回的信息以及您希望如何构建它.您是否希望人们通过典型链接访问您的数据 (http://blog.url/?post=xxx&category=xxx&whatever=xxx)?或者您想继续运行一个典型的博客,但允许通过另一种机制访问 API?

To build it into an 'API' you'd need to first identify what information you're returning and how you want to structure it. Do you want people to access your data via a typical link (http://blog.url/?post=xxx&category=xxx&whatever=xxx)? Or do you want to keep running a typical blog but allow API access through another mechanism?

如果您想要第二条路线,您可以随时将插件挂接到 WordPress 的内置 XMLRPC 服务中.然后用户会发出类似 http://blog 的请求.url/xmlrpc.php?resource=xxx&variable=yyy&somethingelse=zzz 并且您的站点将返回您想要的任何信息(尽管这将是 SOAP,而不是 REST ......所以这真的取决于您).

If you want the second route, you could always hook a plug-in into WordPress' built-in XMLRPC service. Then users will make a request of something like http://blog.url/xmlrpc.php?resource=xxx&variable=yyy&somethingelse=zzz and your site would return whatever information you want (though this would be SOAP, not REST ... so it's really up to you).

见我的回答 此处有关 WordPress 代码的特定示例...

See my answer here for a specific example with WordPress code ...

这篇关于是否有用于从您的站点创建 API 的 wordpress 插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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