API_PM::api_read PHP Method

api_read() public method

api_read function.
public api_read ( ) : void
return void
    function api_read()
    {
        $this->app_check("get");
        if (!isset($this->appAllow["pm"]["read"])) {
            $_arr_return = array("alert" => "x050319");
            $_arr_logTarget[] = array("app_id" => $this->appRequest["app_id"]);
            $_arr_logType = array("pm", "read");
            $this->log_do($_arr_logTarget, "app", $_arr_return, $_arr_logType);
            $this->obj_api->halt_re($_arr_return);
        }
        $_arr_userRow = $this->user_check("get");
        $_num_pmId = fn_getSafe(fn_get("pm_id"), "int", 0);
        if ($_num_pmId < 1) {
            $_arr_return = array("alert" => "x110211");
            $this->obj_api->halt_re($_arr_return);
        }
        $_arr_sign = array("act_get" => $GLOBALS["act_get"], $this->userRequest["user_by"] => $this->userRequest["user_str"], "user_access_token" => $this->userRequest["user_access_token"], "pm_id" => $_num_pmId);
        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_pmRow = $this->mdl_pm->mdl_read($_num_pmId);
        if ($_arr_pmRow["alert"] != "y110102") {
            $this->obj_api->halt_re($_arr_pmRow);
        }
        if ($_arr_pmRow["pm_from"] != $_arr_userRow["user_id"] && $_arr_pmRow["pm_to"] != $_arr_userRow["user_id"]) {
            $_arr_return = array("alert" => "x110403");
            $this->obj_api->halt_re($_arr_return);
        }
        $_arr_pmRow["fromUser"] = $this->mdl_user->mdl_read_api($_arr_pmRow["pm_from"]);
        $_arr_pmRow["toUser"] = $this->mdl_user->mdl_read_api($_arr_pmRow["pm_to"]);
        if ($_arr_pmRow["pm_type"] == "out") {
            $_arr_sendRow = $this->mdl_pm->mdl_read($_arr_pmRow["pm_send_id"]);
            if ($_arr_sendRow["alert"] != "y110102") {
                $_arr_pmRow["pm_send_status"] = "revoke";
            } else {
                $_arr_pmRow["pm_send_status"] = $_arr_sendRow["pm_status"];
            }
        }
        //unset($_arr_pmRow["alert"]);
        $_str_src = fn_jsonEncode($_arr_pmRow, "encode");
        $_str_code = $this->obj_crypt->encrypt($_str_src, $this->appRow["app_key"]);
        $_arr_return = array("code" => $_str_code, "alert" => $_arr_pmRow["alert"]);
        $this->obj_api->halt_re($_arr_return);
    }

Usage Example

Example #1
0
        break;
    case "del":
        $api_pm->api_del();
        //删除
        break;
    case "status":
        $api_pm->api_status();
        //状态
        break;
    case "rev":
    case "revoke":
        $api_pm->api_revoke();
        //撤回
        break;
    default:
        switch ($GLOBALS["act_get"]) {
            case "check":
                $api_pm->api_check();
                //验证是否有新短信
                break;
            case "read":
                $api_pm->api_read();
                //读取
                break;
            case "list":
                $api_pm->api_list();
                //列出
                break;
        }
        break;
}