File: /www/wwwroot/www.scdc-marine.com/wp-content/themes/heku-cms/HekuClass/Common/RestApi.php
<?php namespace Heku\HekuClass\Common;
// use B2\Modules\Templates\Modules\Posts;
// use B2\Modules\Templates\PostType\Announcement;
// use B2\Modules\Templates\Single;
// use B2\Modules\Common\Post;
// use B2\Modules\Common\Shop;
// use B2\Modules\Common\User;
// use B2\Modules\Common\Distribution;
// use B2\Modules\Common\Circle;
// use B2\Modules\Common\FileUpload;
// use B2\Modules\Common\Comment;
// use B2\Modules\Common\Links;
// use B2\Modules\Common\Infomation;
// use B2\Modules\Common\Cpay;
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 );
}
}
}