File: /www/wwwroot/www.scdc-marine.com/wp-content/themes/scdc-marine/HekuClass/Common/RestApi.php
<?php namespace Heku\HekuClass\Common;
class RestApi{
public function init(){
add_action( 'rest_api_init', array($this,'heku_rest_regeister'));
}
public function heku_rest_regeister(){
/**
* 获取当前登录用户的个人信息
*/
register_rest_route('heku/api','/getUserInfo',array(
'methods'=>'get',
'callback'=>array(__CLASS__,'getUserInfo'),
'permission_callback' => '__return_true'
));
/************************************ 登录与注册开始 ************************************************/
}
public static function getUserInfo($request){
$user = \Heku\HekuClass\Common\Login::get_user_info($request['ref']);
return new \WP_REST_Response("",200);
if(isset($res['error'])){
return new \WP_Error('comment_error',$res['error'],array('status'=>403));
}else{
return new \WP_REST_Response( $user , 200 );
}
}
}