姓名+身份证号+人脸动态实名认证(百度)

        $url                        = 'https://aip.baidubce.com/oauth/2.0/token';//地址
        $post_data['grant_type']    = 'client_credentials';
        $post_data['client_id']     = 'xxxx';
        $post_data['client_secret'] = 'xxxx';
        $o                          = "";
        foreach ($post_data as $k => $v) {
            $o .= "$k=" . urlencode($v) . "&";
        }
        $post_data   = substr($o, 0, -1);
        $res         = $this->request_post($url, $post_data);
        $token       = json_decode($res, true)['access_token'];
        $verify_info = $this->http_post("https://aip.baidubce.com/rpc/2.0/brain/solution/faceprint/verifyToken/generate?access_token=" . $token, ['plan_id' => 13472]);
        if ($verify_info['success'] == '') {
            returnApi($verify_info['message']);
        } else {
            $verify_token = $verify_info['result']['verify_token'];
        }
        $userinfo = $this->http_post("https://brain.baidu.com/solution/faceprint/idcard/submit", ['verify_token' => $verify_token, 'id_name' => app('user')->real_name, 'id_no' => app('user')->idcard]);
        if ($userinfo['success'] == '') {
            returnApi($userinfo['message']);
        }
        require_once '../extend/phpqrcode/phpqrcode.php';
        $object               = new \QRcode();
        $errorCorrectionLevel = 'L'; //容错级别
        $matrixPointSize      = 5; //生成图片大小
        //打开缓冲区
        ob_start();
        $data = "https://brain.baidu.com/face/print/?token=" . $verify_token . "&successUrl=http://xxx.cn/home/disend/seccess/&failedUrl=http://xxxx";
        //生成二维码图片
        $returnData = $object->png($data, false, $errorCorrectionLevel, $matrixPointSize, 2);
        //这里就是把生成的图片流从缓冲区保存到内存对象上,使用base64_encode变成编码字符串,通过json返回给页面。
        $imageString = base64_encode(ob_get_contents());
        //关闭缓冲区
        ob_end_clean();
        $base64 = "data:image/png;base64," . $imageString;
   

    public function request_post($url = '', $param = '')
    {
        if (empty($url) || empty($param)) {
            return false;
        }
        $con = file_get_contents($url . '?' . $param);
        return $con;
    }

    public function http_post($url, $data_string)
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'X-AjaxPro-Method:ShowList',
            'Content-Type: application/json; charset=utf-8',
            'Content-Length: ' . strlen(json_encode($data_string)))
        );
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data_string));
        $data = curl_exec($ch);
        curl_close($ch);
        return json_decode($data, true);
    }

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Evelyn丶婉婷

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值