【发布时间】:2018-07-25 00:32:36
【问题描述】:
我想使用 bash 中的 curl 更新帖子元数据。
基本身份验证的授权工作正常,我可以使用 register_rest_field 函数中的预定义字符串更新帖子元。
curl -X POST http://127.0.0.1/exampleporject/wp-json/wp/v2/custompost/53 -H 'content-type: application/json' -d '{"score":10}'
这是正在使用的 curl 命令。正在调用的 REST API 函数是:
register_rest_field( 'custompost', 'post-meta-fields', array(
'get_callback' => function ( $data ) {
return update_post_meta(53,'website_name',$data->score);
}
)
);
我无法获取 $data 对象并获取在 curl 命令中传递的 score 属性。
如何获取在 curl 命令中作为 json 数据传递的 score 属性?
【问题讨论】: