芝麻信用接口

class ZmxyController extends Controller {

  //芝麻信用网关地址
        public $gatewayUrl = "https://zmopenapi.zmxy.com.cn/openapi.do";
        //商户公钥文件
        //芝麻公钥文件
        public $privateKeyFile = "rsa_private_key.pem";
        public $zmPublicKeyFile = "rsa_public_key.pem";

        //数据编码格式
        public $charset = "UTF-8";
        //芝麻分配给商户的appId
        public $appId = "xxx";

    public function index(){

    }
    //生成移动端SDK 集成需要的sign 参数 ,并进行urlEncode
    public function generateSign($cert_name,$cert_no,$certType='IDENTITY_CARD'){

        $client = new \ZmopClient($this->gatewayUrl, $this->appId, $this->charset, $this->privateKeyFile,$this->zmPublicKeyFile);
        $request = new \ZhimaAuthInfoAuthorizeRequest();
        $request->setScene("CQSB");
        // 授权来源渠道设置为appsdk
        $request->setChannel("appsdk");
        // 授权类型设置为2标识为证件号授权见“章节4中的业务入参说明identity_type”
        $request->setIdentityType("2");
        // 构造授权业务入参证件号,姓名,证件类型;“章节4中的业务入参说明identity_param”
        //$request->setIdentityParam("{\"certNo\":\"$certNo\",\"certType\":\"IDENTITY_CARD\", \"name\":\"$name\"}");
        $request->setIdentityParam("{\"identity_type\":\"CERT_INFO\",\"cert_type\":\"IDENTITY_CARD\",\"cert_name\":\"$cert_name\",\"cert_no\":\"$cert_no\"}");// 必要参数 
        // 构造业务入参扩展参数“章节4中的业务入参说明biz_params”
        $request->setBizParams("{\"auth_code\":\"M_APPSDK\"}");

        $params = $client->generateEncryptedParamWithUrlEncode($request);
        $sign = $client->generateSignWithUrlEncode($request);

        $data['gatewayUrl'] = $this->gatewayUrl;
        $data['appId'] = $this->appId;
        $data['charset'] = $this->charset;
        $data['params']=$params;
        $data['sign'] = $sign;
        $this->ajaxreturn(array("desc"=>"成功","code"=>1111,"data"=>$data));
    }


    public function test($cert_name,$cert_no){
         $client = new \ZmopClient($this->gatewayUrl,$this->appId,$this->charset,$this->privateKeyFile,$this->zmPublicKeyFile);

         $request = new \ZhimaCustomerCertificationInitializeRequest();
         $request->setChannel("apppc");
         $request->setPlatform("zmop");

            $request->setTransactionId("CQSB".time());// 必要参数       
            //20161230w1010103000048620621(试用)  
            $request->setProductCode("w1010103000048621629");// 必要参数   

            $request->setBizCode("FACE");// 必要参数         
            $request->setIdentityParam("{\"identity_type\":\"CERT_INFO\",\"cert_type\":\"IDENTITY_CARD\",\"cert_name\":\"$cert_name\",\"cert_no\":\"$cert_no\"}");// 必要参数 
            $request->setExtBizParam("{}");// 必要参数         
            $response = $client->execute($request);
            var_dump($response);die();
          echo json_encode($response);
    }

http://blog.csdn.net/cometo985/article/details/51280201

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值