参考腾讯云官方文档:
前提条件:成功获取NonceTicket。
获取参考文档:
PHP腾讯云人脸核身获取NONCE ticket-CSDN博客
php
function getTxFaceSign(){
$appId = '';
$userId = '';
$version = '1.0.0';
$ticket = '';
if(!$ticket){
return '';
}
$nonce = $this->random(32);
$data = [$appId,$userId,$version,$ticket,$nonce];
asort($data);
$str = '';
foreach ($data as $val) {
$str.= $val;
}
$sign = sha1($str);
}
// 生成随机字符串
function random($length = 6 , $numeric = 0) {
PHP_VERSION < '4.2.0' && mt_srand((double)microtime() * 1000000);
if($numeric) {
$hash = sprintf('%0'.$length.'d', mt_rand(0, pow(10, $length) - 1));
} else {
$hash = '';
$chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789abcdefghjkmnpqrstuvwxyz';
$max = strlen($chars) - 1;
for($i = 0; $i < $length; $i++) {
$hash .= $chars[mt_rand(0, $max)];
}
}
return $hash;
}