【发布时间】:2017-05-24 16:22:25
【问题描述】:
我正在使用 WP REST v2 编写 wordpress REST API。有没有一种方法可以在我们在 register_rest_route 函数中定义的回调函数中处理传入的 JSON 参数(而不是查询参数)?
例如:
function wpplugin_register_routes() {
register_rest_route( 'testapi/v1', 'users', array(
'methods' => 'POST',
'callback' => 'wpplugin_process_json_params',
) );
}
function wpplugin_process_json_params( WP_REST_Request $request ) {
// Process the $request which should be a JSON string
}
【问题讨论】:
标签: wordpress wordpress-rest-api