注册送短信

DEMO: Factor/raw_video_idcard - 活体检测+人口库验证

代码示例

 /*****************
 * 示例代码
 ******************/
//appid参数 appkey参数在     身份认证-创建/管理AppID中获取
$appid      = '*****';                                                                  //appid参数
$appkey     = '****************************';                                           //appkey参数
$timestamp  = time();                                                                   //获取当前时间戳
$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);
}