DEMO: Factor/raw_video_idcard - 活體檢測+人口庫驗證
代碼示例
/*****************
* 示例代碼
******************/
//appid參數(shù) appkey參數(shù)在 身份認證-創(chuàng)建/管理AppID中獲取
$appid = '*****'; //appid參數(shù)
$appkey = '****************************'; //appkey參數(shù)
$timestamp = time(); //獲取當(dāng)前時間戳
$motions = 'BLINK'; //用戶動作序列,BLINK 眨眼;MOUTH 張嘴; NOD 點頭; YAW 搖頭
$complexity = '0'; //活體檢測通過的難易程度,默認為 0, 0:簡單模式;1: 正常模式;2:困難模式;3:地獄模式
$image_flag = 'Y'; //是否需要返回照片,Y/N
$video = curl_file_create('/../...mp4'); //視頻文件
$name = '***'; //驗證用戶姓名
$idNo = '*****************'; //驗證用戶身份證號碼
$temp_data = array(
'appkey' => $appkey,
'timestamp' => $timestamp,
'name' => $name,
'idNo' => $idNo,
);
//生成簽名
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,
'motions' => $motions,
'complexity' => $complexity,
'image_flag' => $image_flag,
'video' => $video
);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://tpa.mysubmail.com/factor/raw_video_idcard",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $post_data,
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
print_r( "cURL Error #:" . $err);
} else {
print_r( $response);
}