humanmade/mercator-rest-api

Mercator 的 REST API 端点

安装: 1

依赖: 0

建议者: 0

安全: 0

星标: 2

关注者: 24

分支: 2

开放问题: 4

类型:wordpress-muplugin

dev-master 2018-12-04 17:13 UTC

This package is auto-updated.

Last update: 2024-09-05 06:52:34 UTC


README

用于处理域名映射的 REST API

要求 WordPress 4.5+ 或 WP REST API 插件

使用方法

您需要包含并实例化控制器

add_action( 'rest_api_init', function() {
    include 'class-rest-api.php';
    $api = new Mercator\REST_API;
    $api->register_routes();
} );

控制器添加了两个 API 路由

/wp-json/mercator/v1/mappings       // accepts GET, POST
/wp-json/mercator/v1/mappings/:id   // accepts PUT, PATCH, DELETE

您还可以通过传递 GET 参数来指定博客 ID

/wp-json/mercator/v1/mappings?blog=1

数据结构

映射非常简单。以下是一个映射的示例 JSON 对象

{
    "id": 1                       // integer
    "domain": "example.com",      // string
    "active": true                // boolean
}

当使用 POST 创建映射时,您只需要发送 domainactive 值。