DEMO: Factor/raw_video - 活體檢測
<?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í)間戳
$motions = 'BLINK'; //用戶動(dòng)作序列,BLINK 眨眼;MOUTH 張嘴; NOD 點(diǎn)頭; YAW 搖頭
$complexity = '0'; //活體檢測通過的難易程度,默認(rèn)為 0, 0:簡單模式;1: 正常模式;2:困難模式;3:地獄模式
$image_flag = 'Y'; //是否需要返回照片,Y/N
$video = curl_file_create('***/***/***.mp4'); //視頻文件
$temp_data = array(
'appkey' => $appkey ,
'timestamp' => $timestamp,
);
//生成簽名
ksort($temp_data);
reset($temp_data);
$signature = hash('sha256', http_build_query($temp_data));
$post_data = array(
'appid' => $appid,
'timestamp' => $timestamp,
'signature' => $signature,
'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",
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) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}