Files
mier-php/application/api/model/AliRealNameVerify.php
2025-08-11 10:22:05 +08:00

57 lines
2.0 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\api\model;
use think\Db;
use think\Model;
class AliRealNameVerify extends Model
{
//身份证二要素认证
public function real_name_verify($real_name, $card_id)
{
$host = "https://eid.shumaidata.com";
$path = "/eid/check";
$method = "POST";
// $appcode = "b984f1e3220649bb8e9a9796808da36f";
$appcode = "c98b2b9cdde747cabd1878dc4eefefc8";
$headers = array();
array_push($headers, "Authorization:APPCODE " . $appcode);
$querys = "idcard=".$card_id."&name=".urlencode($real_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);
//设定返回信息中是否包含响应信息头启用时会将头文件的信息作为数据流输出true 表示输出信息头, false表示不输出信息头
//如果需要将字符串转成json请将 CURLOPT_HEADER 设置成 false
curl_setopt($curl, CURLOPT_HEADER, false);
if (1 == strpos("$".$host, "https://"))
{
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
}
$result = curl_exec($curl);
if($result) {
$arr = json_decode($result, true);
if($arr){
if($arr['code'] == 0) {
return ['code' => 200, 'msg' => '验证成功', 'data' => null];
}else{
return ['code' => 201, 'msg' => '姓名与身份证核验不一致', 'data' => null];
}
}
}
return ['code' => 201, 'msg' => '验证错误', 'data' => null];
}
}