天眼调试API银行卡4要素验证笔记!

2019-11-13  本文已影响0人  DragonersLi
【天眼数据】银行卡四要素(银行卡四元素)实名认证-银行卡四要素鉴权-银行卡四要素校验
调试地址:
https://apigateway.console.aliyun.com/inner/?spm=5176.730006-56956004-57000002-cmapi033467.content.8.4e3e3dc6Zqsw6W#/cn-hangzhou/apps/testApi/0b9395c40c974469a9cabaede8ee39d4/ac267f3bba554804bce3ed9a6bf6c905/RELEASE//CloudMarket
image.png
curl
curl -i -k --get --include 'https://bankcard4c.shumaidata.com/bankcard4c?bankcard=bankcard&idcard=idcard&mobile=mobile&name=name'  -H 'Authorization:APPCODE 你自己的AppCode
php
<?php
    $host = "https://bankcard4c.shumaidata.com";
    $path = "/bankcard4c";
    $method = "GET";
    $appcode = "你自己的AppCode";
    $headers = array();
    array_push($headers, "Authorization:APPCODE " . $appcode);
    $querys = "bankcard=bankcard&idcard=idcard&mobile=mobile&name=name";
    $bodys = "";
    $url = $host . $path . "?" . $querys;

    $curl = curl_init();
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($curl, CURLOPT_FAILONERROR, false);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_HEADER, true);
    if (1 == strpos("$".$host, "https://"))
    {
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
    }
    var_dump(curl_exec($curl));
?>
代码优化:

  /*
     * 测试方法
     */
public function test(){
   $url = "https://bankcard4c.shumaidata.com/bankcard4c";
        $headers = ["Authorization:APPCODE " . "32位的appcode"];
        $data = [
            'name' => '姓名',
            'mobile' => '手机',
            'idcard' => '身份证',
            'bankcard' => '银行卡',
        ];
        $res = $this->httpRequest($url,$data,$headers);
}
  /*
     * 请求地址:$url
     * 请求数据:$data
     * 请求头数据:$headers
     * 请求方法:$method
     * 返回数据:json格式
     */
    public function httpRequest($url = '',$data=[],$headers = [],$method = 'GET')
    {

        $curl = curl_init();
        curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
        curl_setopt($curl, CURLOPT_URL, $url  . "?" . http_build_query($data));
        curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($curl, CURLOPT_FAILONERROR, false);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_HEADER, false);
        $ssl = substr($url, 0, 8) == "https://" ? TRUE : FALSE;
        if ($ssl)
        {
            curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);//不进行严格认证
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);//不进行SSL证书认证
        }
        $output = curl_exec($curl);
        curl_close($curl);
        return $output;
    }


返回数据:
string(140) "{"msg":"","success":true,"code":200,"data":{"result":0,"order_no":"644262386429202432","desc":"信息一致,匹配成功","msg":"一致"}}"
image.png
image.png
上一篇下一篇

猜你喜欢

热点阅读