系统开发的时候经常会需要对用户做什么认证,用户提交的身份证信息如何对其进行真实性判定呢?我们已通过阿里云提供的身份证实名认证接口对信息进行验证,通过接口将用户提交的信息转送至身份证核验中心进行核验。
先购买接口服务:https://market.aliyun.com/products/57000002/cmapi025518.html#sku=yuncode1951800000
下面是对其认证的实例程序:
<?php
$host = "https://idenauthen.market.alicloudapi.com";
$path = "/idenAuthentication";
$method = "POST";
$appcode = "你自己的AppCode"; //服务购买成功之后点击跳转至阿里云控制台,可看到AppCode
$headers = array();
array_push($headers, "Authorization:APPCODE " . $appcode);
//根据API的要求,定义相对应的Content-Type
array_push($headers, "Content-Type".":"."application/x-www-form-urlencoded; charset=UTF-8");
$querys = "";
$bodys = "idNo=340421190210182345&name=%E5%BC%A0%E4%B8%89";
$url = $host . $path;
$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);
}
curl_setopt($curl, CURLOPT_POSTFIELDS, $bodys);
var_dump(curl_exec($curl));
curl_close( $curl );
$result_json = json_decode($response,true);
?>
返回示例:
{
"name": "张三",
"idNo": "340421190710145412",
"respMessage": "身份证信息匹配",
"respCode": "0000",
"province": "安徽省",
"city": "淮南市",
"county": "凤台县",
"birthday": "19071014",
"sex": "M",
"age": "111"
}
其他详细信息在页面中间都有说明,其他不明白的地方可以联系交流!
搬砖快乐!