[英]WP REST API, no data is fetched
I'm totally new this API, OAuth stuff in WordPress and I'm trying to list all the users as a JSON and make them usable in a client app.我是全新的这个 API,WordPress 中的 OAuth 东西,我试图将所有用户列为 JSON,并使它们在客户端应用程序中可用。
What I did was installing this little plugin WP REST API (WP API) and trying to list a user via the address mysite.com/wp-json/users/4
.我所做的是安装这个小插件WP REST API (WP API)并尝试通过地址mysite.com/wp-json/users/4
列出用户。 But, it just gives me this message但是,它只是给了我这个信息
[{"code":"json_user_cannot_list","message":"Sorry, you are not allowed to list users."}]
I did changed Permalinks too.我也改变了永久链接。 But no luck!但没有运气!
What's wrong in this ?这有什么问题?
根据其文档,您使用的是哪个版本的插件,版本 2 可以访问这样的文件
使用链接为https://wordpress.org/plugins/rest-api/ 的版本 2 这将启用查询方式。您也可以阅读版本 1 描述以了解更多详细信息
implement get_user()
method of WP_REST_CONTROLLER
实现WP_REST_CONTROLLER
get_user()
方法
protected function get_user() {
$error = new WP_Error(
'rest_user_invalid_id',
__( 'Invalid user ID.' ),
array( 'status' => 404 )
);
// if ( (int) $id <= 0 ) {
// return $error;
// }
// $user = get_userdata($user_email);
// if ( empty( $user ) || ! $user->exists() ) {
// return $error;
// }
// if ( is_multisite() && ! is_user_member_of_blog( $user->ID ) ) {
// return $error;
// }
return $user;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.