API_USER::api_refresh_token PHP Метод

api_refresh_token() публичный Метод

public api_refresh_token ( )
    function api_refresh_token()
    {
        $this->app_check("post");
        $_arr_userSubmit = $this->mdl_user->input_refresh_api();
        if ($_arr_userSubmit["alert"] != "ok") {
            $this->obj_api->halt_re($_arr_userSubmit);
        }
        $_arr_sign = array("act_post" => $GLOBALS["act_post"], $_arr_userSubmit["user_by"] => $_arr_userSubmit["user_str"], "user_refresh_token" => $_arr_userSubmit["user_refresh_token"]);
        if (!$this->obj_sign->sign_check(array_merge($this->appRequest, $_arr_sign), $this->appRequest["signature"])) {
            $_arr_return = array("alert" => "x050403");
            $this->obj_api->halt_re($_arr_return);
        }
        $_arr_userRow = $this->mdl_user->mdl_read($_arr_userSubmit["user_str"], $_arr_userSubmit["user_by"]);
        if ($_arr_userRow["alert"] != "y010102") {
            $this->obj_api->halt_re($_arr_userRow);
        }
        if ($_arr_userRow["user_status"] == "disable") {
            $_arr_return = array("alert" => "x010401");
            $this->obj_api->halt_re($_arr_return);
        }
        if ($_arr_userRow["user_refresh_expire"] < time()) {
            $_arr_return = array("alert" => "x010235");
            $this->obj_api->halt_re($_arr_return);
        }
        if ($_arr_userSubmit["user_refresh_token"] != $_arr_userRow["user_refresh_token"]) {
            $_arr_return = array("alert" => "x010234");
            $this->obj_api->halt_re($_arr_return);
        }
        //print_r($_arr_userRow);
        $_arr_userRowRefresh = $this->mdl_user->mdl_refresh($_arr_userRow["user_id"]);
        unset($_arr_userRow["user_rand"], $_arr_userRow["user_pass"], $_arr_userRow["user_note"]);
        $_arr_userRow["user_access_token"] = $_arr_userRowRefresh["user_access_token"];
        $_arr_userRow["user_access_expire"] = $_arr_userRowRefresh["user_access_expire"];
        //unset($_arr_userRow["alert"]);
        $_str_src = fn_jsonEncode($_arr_userRow, "encode");
        $_str_code = $this->obj_crypt->encrypt($_str_src, $this->appRow["app_key"]);
        $_arr_return = array("code" => $_str_code);
        $_arr_return["alert"] = "y010411";
        $this->obj_api->halt_re($_arr_return);
    }

Usage Example

Пример #1
0
}
include_once BG_PATH_FUNC . "init.func.php";
//初始化
$arr_set = array("base" => true, "header" => "Content-type: application/json; charset=utf-8", "db" => true, "type" => "ajax");
fn_init($arr_set);
include_once BG_PATH_CONTROL . "api/user.class.php";
//载入用户控制器
$api_user = new API_USER();
//初始化用户
switch ($GLOBALS["act_post"]) {
    case "reg":
        $api_user->api_reg();
        //注册
        break;
    case "refresh_token":
        $api_user->api_refresh_token();
        //刷新访问口令
        break;
    case "login":
        $api_user->api_login();
        //登录
        break;
    case "edit":
        $api_user->api_edit();
        //编辑
        break;
    case "mailbox":
        $api_user->api_mailbox();
        //更换邮箱
        break;
    case "nomail":