传入姓名、身份证号,校验此二要素是否一致,同时返回生日、性别、籍贯等信息。
function getCard($idcard, $name)
{
$host = "https://eid.shumaidata.com";
$path = "/eid/check";
$method = "POST";
$appcode = "a277cc985ba54c388e72deb135d45e9d";
$headers = array();
array_push($headers, "Authorization:APPCODE " . $appcode);
$querys = "idcard=" . $idcard . "&name=" . urlencode($name);
$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, 1);
curl_setopt($curl, CURLOPT_HEADER, false);
if (strpos("$" . $host, "https://") == 1) {
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
}
$output = rtrim(curl_exec($curl), 1);//删除结尾的多余字符;
curl_close($curl);
return json_decode($output, true);
}
rtrim(curl_exec($curl), 1);//官方接口通过$curl爬取过来的内容,结尾存在“1”这样的异常数据,导致无法正常解析。通过rtrim函数删除结尾的多余字符。
同名不同身份证号也将审核通过。
@lockdata.cn