DEMO: Factor/idcard4 - 身份證四要素
<?php
/*****************
* 示例代碼
******************/
//appid參數(shù) appkey參數(shù)在 身份認(rèn)證-創(chuàng)建/管理AppID中獲取
$appid = '6***3'; //appid參數(shù)
$appkey = '5d****************************58'; //appkey參數(shù)
$timestamp = time(); //獲取當(dāng)前時(shí)間戳
$name = '***'; //待驗(yàn)證用戶(hù)姓名
$idNo = '3****************3'; //待驗(yàn)證用戶(hù) 身份證號(hào)碼
$begin_date = '20051231'; //身份證背面有效時(shí)間---開(kāi)始時(shí)間 格式 20051231
$end_date = '20051231'; //身份證背面有效時(shí)間---結(jié)束時(shí)間 格式 20051231
$temp_data = array(
'appkey' => $appkey ,
'timestamp' => $timestamp,
'idNo' => $idNo,
'name' => $name,
);
//生成簽名
ksort($temp_data);
reset($temp_data);
$signature = hash('sha256', http_build_query($temp_data));
$post_data = array(
'appid' => $appid,
'timestamp' => $timestamp,
'signature' => $signature,
'name' => $name,
'idNo' => $idNo,
'begin_date'=> $begin_date,
'end_date' => $end_date,
);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://tpa.mysubmail.com/factor/idcard4",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => http_build_query($post_data),
CURLOPT_HTTPHEADER => array("Content-Type: application/x-www-form-urlencoded"),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}