聚石塔,御城河接入,御河城安全整改demo

去年做了御城河接入,怕忘记和丢失代码,所以在这里做个记录,也是方便其他人 操作使用吧

我用的是PHP框架  tp5,如果你也是那么你复制后改一下参数就哦了

完整文件到这里下载  传送-->

配置文件

聚石塔,御城河接入,御河城安全整改demo_第1张图片

这个里主要代码

accountHost . "computeRisk";
        $params= $this->isVerifyPassedParam();
        $params['time'] = date('Y-m-d H:i:s');
        $params['appKey'] = $this->topAppkey;
        $sdk = new YchClientController($this->appkey, $this->secret);
        $rsp = $sdk->send($url ,$params);
        $this->parseResult($rsp);
    }


    /**
     *  2.0 获取二次验证地址(getVerifyUrl)接口(仅限B/S架构调用)
     * https://php.z55.club/api/test/getVerifyUrl
     */
    public function getVerifyUrl(){
        $url = $this->accountHost . "getVerifyUrl";
        $params = $this->isVerifyPassedParam();

        $params['sessionId'] = md5(time());
        $params['mobile'] = '1500000000';
        $params['appId'] = '江苏移动号卡';
        $params['redirectURL'] = urlencode('https://php.z55.club/api/test/isVerifyPassed');



        $params['userId'] = $this->defaultParam["userId"];
        $params['userIp'] = $this->defaultParam["userIp"];
        $params['ati'] = $this->defaultParam["ati"];
        $params['appId'] = $this->topAppkey;
        $params['appName'] = $this->defaultParam["appName"];
        $params['appKey'] =  $this->appkey;
        $params['time'] =  date('Y-m-d H:i:s');


        $sdk = new YchClientController($this->appkey, $this->secret);
        $rsp = $sdk->send($url ,$params);//verifyUrl

        echo $rsp;die;

        $rsp_json = json_decode($rsp, true);



        return redirect($rsp_json['verifyUrl']);
    }

    /**
     * 3.0 获取二次验证令牌(getVerifyToken) 接口(仅限C/S架构调用)
     * https://php.z55.club/api/test/getVerifyToken
     */
    public function getVerifyToken(){
        $url = $this->accountHost . "getVerifyToken";
        $params = $this->isVerifyPassedParam();

        $params['sessionId'] =md5(time());
        $params['mobile'] = '123456';
        $params['appId'] = '江苏移动号卡';
        $params['appKey'] = '123456';

        $sdk = new YchClientController($this->appkey, $this->secret);
        $rsp = $sdk->send($url ,$params);
        $rsp_json = json_decode($rsp, true);
        return $rsp_json['token'];
    }

    /**
     * 4.0 发送验证码(sendVerifyCode)接口(仅限C/S架构调用)
     * https://php.z55.club/api/test/sendVerifyCode
     */
    public function sendVerifyCode() {
        $url = "http://account.ose.aliyun.com/sendVerifyCode";
        $params['token'] = $this->getVerifyToken();
        $params['time'] = date('Y-m-d H:i:s');
        $params['appKey'] = $this->topAppkey;
        $sdk = new YchClientController($this->appkey, $this->secret);
        $rsp = $sdk->send($url ,$params);
        $this->parseResult($rsp);
    }


    /**
     * 5.0 检查验证码(checkVerifyCode)接口(C/S架构调用)
     * https://php.z55.club/api/test/checkVerifyCode?t=102560
     */
    public function checkVerifyCode(){
        $url = $this->accountHost . "checkVerifyCode";
        $params['token'] = $this->getVerifyToken();
        $params['captcha'] = input('t');
        $params['time'] = date('Y-m-d H:i:s');
        $params['appKey'] = $this->appkey;
        $sdk = new YchClientController($this->appkey, $this->secret);
        $rsp = $sdk->send($url ,$params);
        $this->parseResult($rsp);
    }


    /**
     * 6.0 是否验证通过(isVerifyPassed)接口
     * https://php.z55.club/api/test/isVerifyPassed
     */
    public function isVerifyPassed() {
        $url = $this->accountHost . "isVerifyPassed";
        $params['token'] = input('token');
        $params['time'] = date('Y-m-d H:i:s');
        $params['appKey'] = $this->topAppkey;
        $sdk = new YchClientController($this->appkey, $this->secret);
        $rsp = $sdk->send($url ,$params);
        $this->parseResult($rsp);
    }




}

基本顺序就是按着1-6执行就行

你可能感兴趣的:(PHP)