參考騰訊云官方文檔:
人臉核身 生成 SDK 接口調用步驟使用簽名_騰訊云
前提條件:成功獲取NonceTicket。
獲取參考文檔:
PHP騰訊云人臉核身獲取NONCE ticket-CSDN博客
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;
}