wordpress api_WordPress JSON API插件

wordpress api

Ever since I moved to a mostly-JavaScript job, I've become more and more enamored with the simplicity and usefulness of JSON.  Now I want everything available in JSON format, and when I encounter a service which doesn't provide a JSON API, I have a fit.  I was recently brainstorming a way to place my website into a Dojo/Dijit widget and realized that WordPress doesn't provide a native JSON method of retrieving post information.  Enter the awesome JSON API plugin.

自从我从事以JavaScript为主的工作以来,我对JSON的简单性和实用性越来越着迷。 现在,我希望所有内容都可以使用JSON格式,并且当我遇到不提供JSON API的服务时, 就很满意 。 最近,我正在集思广益,将网站放置在Dojo / Dijit小部件中,并意识到WordPress没有提供本机JSON方法来检索帖子信息。 输入很棒的JSON API插件

下载并安装JSON API插件 (Download & Install the JSON API Plugin)

The plugin is available at the WordPress website:

该插件可在WordPress网站上找到:

http://wordpress.org/extend/plugins/json-api/

http://wordpress.org/extend/plugins/json-api/

Download and install from the WordPress Admin interface.

从WordPress管理界面下载并安装。

配置插件 (Configure the Plugin)

The plugin features three main functionality:

该插件具有三个主要功能:

  • Core:  Basic methods for pulling standard post/category/tag/etc. data.

    核心:提取标准帖子/类别/标签/等的基本方法。 数据。
  • Posts:  Provides additional functionality with regard to posts, including post creation.

    帖子:提供有关帖子的其他功能,包括帖子创建。
  • Respond:  Provides comment and trackback submission methods.

    响应:提供评论和引用提交方法。

Most people will only need the "Core" method enabled.  Advanced users can have a shot at post and comment management.

大多数人只需要启用“核心”方法。 高级用户可以对帖子和评论进行管理。

使用插件 (Using the Plugin)

The plugin has a billion uses and methods, all of which are documented at the following address:

该插件有十亿个用途和方法,所有用法和方法都记录在以下地址:

http://wordpress.org/extend/plugins/json-api/other_notes/

http://wordpress.org/extend/plugins/json-api/other_notes/

A few of the more useful methods include pulling all categories...

一些更有用的方法包括拉出所有类别...


/*
url ?json=get_category_index
*/
{
  "status": "ok",
  "count": 3,
  "categories": [
    { ... },
    { ... },
    { ... }
  ]
}//....


...and retrieving all posts in a given category...

...并检索给定类别中的所有帖子...


/*
url ?json=get_category_posts&slug=mootools
*/
{
  "status": "ok",
  "count": 10,
  "count_total": 79,
  "pages": 7,
  "category": { ... }
  "posts": [
    { ... },
    { ... },
    ...
  ]
}//....


...or just grabbing recent posts:

...或者只是抓取最近的帖子:


/*
url ?json=get_recent_posts&count=10
*/
{
  "status": "ok",
  "count": 10,
  "count_total": 79,
  "pages": 7,
  "posts": [
    { ... },
    { ... },
    ...
  ]
}//....


As I mentioned above, there are a dozens of parameters you can provide to the plugin to fetch JSON data.

如上文所述,您可以向插件提供许多参数来获取JSON数据。

善与恶 (Take the Good with the Bad)

My only concern about this plugin is that it provides a anyone with the ability to sniff out all of your posts using a JSONP library.  That's not the burden of the plugin creator -- just a thought from me.

我对此插件的唯一担心是,它为任何人提供了使用JSONP库嗅探您所有帖子的功能。 这不是插件创建者的负担-只是我的一个想法。

Look forward to a sample usage post from me soon!

期待不久后收到我的样本用法帖子!

翻译自: https://davidwalsh.name/wordpress-json-plugin

wordpress api

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值