Userauth.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. use think\Cache;
  6. use TencentCloud\Common\Credential;
  7. use TencentCloud\Common\Profile\ClientProfile;
  8. use TencentCloud\Common\Profile\HttpProfile;
  9. use TencentCloud\Common\Exception\TencentCloudSDKException;
  10. //use TencentCloud\Faceid\V20180301\FaceidClient;
  11. //use TencentCloud\Faceid\V20180301\Models\IdCardVerificationRequest;
  12. use TencentCloud\Iai\V20200303\IaiClient;
  13. use TencentCloud\Iai\V20200303\Models\CompareFaceRequest;
  14. use fast\Random;
  15. /**
  16. * 实名认证,真人认证相关
  17. */
  18. class Userauth extends Api
  19. {
  20. protected $noNeedLogin = [];
  21. protected $noNeedRight = '*';
  22. //实名认证信息
  23. public function idcard_info(){
  24. $check = Db::name('user_idconfirm')->where('user_id',$this->auth->id)->order('id desc')->find();
  25. $this->success('success',$check);
  26. }
  27. //申请实名认证
  28. public function apply_idcard_confirm(){
  29. $truename = input('truename','');
  30. $idcard = input('idcard' ,'');
  31. if(empty($truename) || empty($idcard)){
  32. $this->error('实名认证信息必填');
  33. }
  34. if($this->auth->idcard_status == 1){
  35. $this->error('您已经完成实名认证');
  36. }
  37. if($this->auth->idcard_status == 0){
  38. $this->error('您已经提交实名认证,请等待审核');
  39. }
  40. Db::startTrans();
  41. $check = Db::name('user_idconfirm')->where('user_id',$this->auth->id)->lock(true)->find();
  42. if(!empty($check)){
  43. if($check['status'] == 0){
  44. Db::rollback();
  45. $this->error('您已经提交实名认证,请等待审核');
  46. }
  47. if($check['status'] == 1){
  48. Db::rollback();
  49. $this->error('您已经完成实名认证');
  50. }
  51. }
  52. $count = Db::name('user_idconfirm')->where(['idcard' => $idcard, 'user_id' => ['neq', $this->auth->id]])->count('id');
  53. if ($count) {
  54. $this->error('该身份证号已被他人使用');
  55. }
  56. //限制每日请求次数
  57. $time = time();
  58. $today_end = strtotime(date('Y-m-d 23:59:59', $time));
  59. $cache_time = $today_end - $time; //缓存时间
  60. $time_count = Cache::get('fourauth' . $this->auth->id);
  61. if (!$time_count) {
  62. Cache::set('fourauth' . $this->auth->id, 1, $cache_time);
  63. } else {
  64. Cache::set('fourauth' . $this->auth->id, $time_count + 1, $cache_time);
  65. if ($time_count > 5) {
  66. $this->error('今日实名次数已到上限,明天再来吧');
  67. }
  68. }
  69. if($this->auth->gender == 0){
  70. //阿里云身份证二要素认证
  71. $auth_restult = $this->userauth_aliyun_two($idcard, $truename);
  72. if($auth_restult == false){
  73. $this->error('身份证信息与姓名不符');
  74. }
  75. }
  76. $data = [
  77. 'user_id' => $this->auth->id,
  78. 'truename' => $truename,
  79. 'idcard' => $idcard,
  80. 'status' => 1, //不需要人工刚审核了,直接过审
  81. 'createtime' => time(),
  82. 'updatetime' => time(),
  83. ];
  84. if($this->auth->gender == 1){
  85. $data['status'] = 0;//男性待审
  86. }
  87. //更新
  88. $update_rs = Db::name('user')->where('id',$this->auth->id)->update(['idcard_status'=>$data['status']]);
  89. if(!empty($check)){
  90. $rs = Db::name('user_idconfirm')->where('id',$check['id'])->update($data);
  91. }else{
  92. $rs = Db::name('user_idconfirm')->insertGetId($data);
  93. }
  94. if($this->auth->gender == 0){
  95. //task任务
  96. //实名认证
  97. $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,5);
  98. if($task_rs === false){
  99. Db::rollback();
  100. $this->error('完成任务失败');
  101. }
  102. //系统消息
  103. $msg_id = \app\common\model\Message::addMessage($this->auth->id,'实名认证','实名认证已经审核通过');
  104. }
  105. if(!$rs || !$update_rs){
  106. Db::rollback();
  107. $this->error('提交失败');
  108. }
  109. Db::commit();
  110. if($this->auth->gender == 0){
  111. $this->success('认证通过');
  112. }else{
  113. $this->success('提交成功,请等待审核');
  114. }
  115. }
  116. //产品链接:https://market.aliyun.com/products/57000002/cmapi026109.html#sku=yuncode20109000025
  117. //阿里云-数脉api
  118. //姓名+身份证号
  119. private function userauth_aliyun_two($cardNo = '',$realname = ''){
  120. if(!$cardNo || !$realname){
  121. return false;
  122. }
  123. $config = config('aliyun_auth_shumai_two');
  124. $host = "https://eid.shumaidata.com";
  125. $path = "/eid/check";
  126. $method = "POST";
  127. $appcode = $config['app_code'];
  128. $headers = array();
  129. array_push($headers, "Authorization:APPCODE " . $appcode);
  130. $querys = "idcard=".$cardNo."&name=".urlencode($realname);
  131. $bodys = '';
  132. $url = $host . $path . "?" . $querys;
  133. $curl = curl_init();
  134. curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
  135. curl_setopt($curl, CURLOPT_URL, $url);
  136. curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
  137. curl_setopt($curl, CURLOPT_FAILONERROR, false);
  138. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  139. //设定返回信息中是否包含响应信息头,启用时会将头文件的信息作为数据流输出,true 表示输出信息头, false表示不输出信息头
  140. //如果需要将字符串转成json,请将 CURLOPT_HEADER 设置成 false
  141. curl_setopt($curl, CURLOPT_HEADER, false);
  142. if (1 == strpos("$".$host, "https://"))
  143. {
  144. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  145. curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
  146. }
  147. $returnRes = curl_exec($curl);
  148. //var_dump($returnRes);
  149. curl_close($curl);
  150. $result = json_decode($returnRes,true);
  151. //dump($result);
  152. if(is_array($result) && isset($result['code']) && $result['code'] == 0){
  153. if(isset($result['result']) && isset($result['result']['res'])){
  154. if($result['result']['res'] == 1){
  155. //实名过了
  156. return true;
  157. }
  158. }
  159. }
  160. return false;
  161. }
  162. //产品链接:https://market.aliyun.com/products/57000002/cmapi026100.html?spm=5176.730005.result.8.1dbc123e8ArY19&innerSource=search#sku=yuncode2010000006
  163. //阿里云-数脉api
  164. //姓名+手机号+身份证号
  165. private function userauth_aliyun_three($cardNo = '',$realname = '',$mobile = ''){
  166. if(!$cardNo || !$realname || !$mobile){
  167. return false;
  168. }
  169. $config = config('aliyun_auth_shumai');
  170. $host = "https://mobile3elements.shumaidata.com";
  171. $path = "/mobile/verify_real_name";
  172. $method = "POST";
  173. $appcode = $config['app_code'];
  174. $headers = array();
  175. array_push($headers, "Authorization:APPCODE " . $appcode);
  176. //根据API的要求,定义相对应的Content-Type
  177. array_push($headers, "Content-Type".":"."application/x-www-form-urlencoded; charset=UTF-8");
  178. $querys = "";
  179. $bodys = "idcard=".$cardNo."&mobile=".$mobile."&name=".urlencode($realname);
  180. $url = $host . $path;
  181. $curl = curl_init();
  182. curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
  183. curl_setopt($curl, CURLOPT_URL, $url);
  184. curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
  185. curl_setopt($curl, CURLOPT_FAILONERROR, false);
  186. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  187. //设定返回信息中是否包含响应信息头,启用时会将头文件的信息作为数据流输出,true 表示输出信息头, false表示不输出信息头
  188. //如果需要将字符串转成json,请将 CURLOPT_HEADER 设置成 false
  189. curl_setopt($curl, CURLOPT_HEADER, false);
  190. if (1 == strpos("$".$host, "https://"))
  191. {
  192. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  193. curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
  194. }
  195. curl_setopt($curl, CURLOPT_POSTFIELDS, $bodys);
  196. $returnRes = curl_exec($curl);
  197. curl_close($curl);
  198. $result = json_decode($returnRes,true);
  199. if(is_array($result) && isset($result['code']) && $result['code'] == 0){
  200. if(isset($result['result']) && isset($result['result']['res'])){
  201. if($result['result']['res'] == 1){
  202. //实名过了
  203. return true;
  204. }
  205. }
  206. }
  207. return false;
  208. }
  209. ///////////////////////////////////////////真人认证,来自知音////////////
  210. //申请真人认证
  211. public function realauth() {
  212. if ($this->auth->real_status == 1) {
  213. $this->error('您已经真人认证过了~');
  214. }
  215. if ($this->auth->avatar == config('avatar_boy') || $this->auth->avatar == config('avatar_girl')) {
  216. $this->error('请先上传真人头像~');
  217. }
  218. $check = Db::name('user_audit')->where('user_id',$this->auth->id)->where('type','avatar')->where('status',0)->find();
  219. if(!empty($check)){
  220. $this->error('您的头像还在审核中,审核完成在认证吧');
  221. }
  222. //获取token
  223. $token_url = 'https://miniprogram-kyc.tencentcloudapi.com/api/oauth2/access_token?app_id='.config('tencent_yun')['secret_id'].'&secret='.config('tencent_yun')['secret_key'].'&grant_type=client_credential&version=1.0.0';
  224. $token_result = file_get_contents($token_url);
  225. if (!$token_result) {
  226. $this->error('您的网络开小差啦1~');
  227. }
  228. $token_result = json_decode($token_result, true);
  229. if ($token_result['code'] != 0) {
  230. $this->error('您的网络开小差啦2~');
  231. }
  232. $token = $token_result['access_token'];
  233. //获取签名鉴权参数ticket
  234. $ticket_url = 'https://miniprogram-kyc.tencentcloudapi.com/api/oauth2/api_ticket?app_id='.config('tencent_yun')['secret_id'].'&access_token='.$token.'&type=SIGN&version=1.0.0';
  235. $ticket_result = file_get_contents($ticket_url);
  236. if (!$ticket_result) {
  237. $this->error('您的网络开小差啦3~');
  238. }
  239. $ticket_result = json_decode($ticket_result, true);
  240. if ($ticket_result['code'] != 0) {
  241. $this->error('您的网络开小差啦4~');
  242. }
  243. $ticket = $ticket_result['tickets'][0]['value'];
  244. //获取签名
  245. $sign_data = [
  246. 'wbappid' => config('tencent_yun')['secret_id'],
  247. 'userId' => (string)$this->auth->id,
  248. 'version' => '1.0.0',
  249. 'ticket' => $ticket,
  250. 'nonce' => Random::alnum(32)
  251. ];//p($sign_data);
  252. asort($sign_data); //p($sign_data);//排序
  253. $sign_string = join('', $sign_data);//p($sign_string);
  254. $sign = sha1($sign_string);//p($sign);
  255. //上传身份信息
  256. $orderNo = createUniqueNo('A',$this->auth->id); //商户请求的唯一标识
  257. $url = 'https://miniprogram-kyc.tencentcloudapi.com/api/server/getAdvFaceId?orderNo=' . $orderNo;
  258. $avatar = one_domain_image($this->auth->avatar);
  259. $avatar = str_replace('https', 'http', $avatar);
  260. $img = file_get_contents($avatar);
  261. $img = str_replace('data:image/jpg;base64', '', $img);
  262. $img = str_replace('\n', '', $img);
  263. $sourcePhotoStr = base64_encode($img);
  264. $data = [
  265. 'webankAppId' => config('tencent_yun')['secret_id'],
  266. 'orderNo' => $orderNo,
  267. 'userId' => (string)$this->auth->id,
  268. 'sourcePhotoStr' => $sourcePhotoStr,
  269. 'sourcePhotoType' => 2,
  270. 'version' => '1.0.0',
  271. 'sign' => $sign,
  272. 'nonce' => $sign_data['nonce']
  273. ];
  274. $rs = curl_post($url,json_encode($data, 320), ['Content-Type: application/json']);
  275. if (!$rs) {
  276. $this->error('您的网络开小差啦5~');
  277. }
  278. $rs = json_decode($rs, true);
  279. if (!$rs || $rs['code'] != 0) {
  280. $this->error('您的网络开小差啦6~');
  281. }
  282. $user_auth = [
  283. 'user_id' => $this->auth->id,
  284. 'certify_id' => $rs['result']['faceId'],
  285. 'out_trade_no' => $data['orderNo'],
  286. 'status' => 0,
  287. 'createtime' => time(),
  288. 'updatetime' => time()
  289. ];
  290. //开启事务
  291. Db::startTrans();
  292. //查询是否认证过
  293. $info = Db::name('user_auth')->where(['user_id' => $this->auth->id])->find();
  294. if ($info) {
  295. $auth_rs = Db::name('user_auth')->where(['id' => $info['id']])->setField($user_auth);
  296. } else {
  297. $auth_rs = Db::name('user_auth')->insertGetId($user_auth);
  298. }
  299. if (!$auth_rs) {
  300. Db::rollback();
  301. $this->error('您的网络开小差啦7~');
  302. }
  303. //修改用户表认证状态
  304. $user_rs = Db::name('user')->where(['id' => $this->auth->id])->setField('real_status', 0);
  305. if ($user_rs === false) {
  306. Db::rollback();
  307. $this->error('您的网络开小差啦8~');
  308. }
  309. Db::commit();
  310. $return_data = [
  311. 'face_id' => $user_auth['certify_id'],
  312. 'order_no' => $user_auth['out_trade_no'],
  313. 'user_id' => (string)$this->auth->id,
  314. 'nonce' => $sign_data['nonce'],
  315. 'sign' => $sign
  316. ];
  317. $this->success('success', $return_data);
  318. }
  319. //查询真人认证结果
  320. public function getrealauthresult() {
  321. $user_auth = Db::name('user_auth')->where(['user_id' => $this->auth->id])->find();
  322. if (!$user_auth) {
  323. $this->success('尚未认证');
  324. }
  325. if ($user_auth['status'] == 1) {
  326. $this->success('真人认证通过');
  327. }
  328. if (!$user_auth['certify_id']) {
  329. $this->success('请先进行真人认证');
  330. }
  331. //获取token
  332. $token_url = 'https://miniprogram-kyc.tencentcloudapi.com/api/oauth2/access_token?app_id='.config('tencent_yun')['secret_id'].'&secret='.config('tencent_yun')['secret_key'].'&grant_type=client_credential&version=1.0.0';
  333. $token_result = file_get_contents($token_url);
  334. if (!$token_result) {
  335. $this->error('您的网络开小差啦1~');
  336. }
  337. $token_result = json_decode($token_result, true);
  338. if ($token_result['code'] != 0) {
  339. $this->error('您的网络开小差啦2~');
  340. }
  341. $token = $token_result['access_token'];
  342. //获取签名鉴权参数ticket
  343. $ticket_url = 'https://miniprogram-kyc.tencentcloudapi.com/api/oauth2/api_ticket?app_id='.config('tencent_yun')['secret_id'].'&access_token='.$token.'&type=SIGN&version=1.0.0';
  344. $ticket_result = file_get_contents($ticket_url);
  345. if (!$ticket_result) {
  346. $this->error('您的网络开小差啦3~');
  347. }
  348. $ticket_result = json_decode($ticket_result, true);
  349. if ($ticket_result['code'] != 0) {
  350. $this->error('您的网络开小差啦4~');
  351. }
  352. $ticket = $ticket_result['tickets'][0]['value'];
  353. //获取签名
  354. $sign_data = [
  355. 'wbappid' => config('tencent_yun')['secret_id'],
  356. 'orderNo' => $user_auth['out_trade_no'],
  357. 'version' => '1.0.0',
  358. 'ticket' => $ticket,
  359. 'nonce' => Random::alnum(32)
  360. ];//p($sign_data);
  361. asort($sign_data); //p($sign_data);//排序
  362. $sign_string = join('', $sign_data);//p($sign_string);
  363. $sign = sha1($sign_string);//p($sign);
  364. //人脸核身结果查询
  365. $url = 'https://miniprogram-kyc.tencentcloudapi.com/api/v2/base/queryfacerecord?orderNo=' . $user_auth['out_trade_no'];
  366. $data = [
  367. 'appId' => config('tencent_yun')['secret_id'],
  368. 'version' => '1.0.0',
  369. 'nonce' => $sign_data['nonce'],
  370. 'orderNo' => $user_auth['out_trade_no'],
  371. 'sign' => $sign
  372. ];
  373. $rs = curl_post($url,json_encode($data, 320), ['Content-Type: application/json']);
  374. if (!$rs) {
  375. $this->error('您的网络开小差啦5~');
  376. }
  377. $rs = json_decode($rs, true);
  378. if (!$rs || $rs['code'] != 0) {
  379. $this->error($rs['msg']);
  380. }
  381. if ($rs['result']['liveRate'] >= 90 && $rs['result']['similarity'] >= 90) {
  382. $edit_data['status'] = 1;
  383. $msg = '真人认证成功';
  384. } else {
  385. $edit_data['status'] = 2;
  386. $edit_data['certify_id'] = '';
  387. $edit_data['out_trade_no'] = '';
  388. $msg = '真人认证失败';
  389. }
  390. $edit_data['updatetime'] = time();
  391. //开启事务
  392. Db::startTrans();
  393. //修改认证信息
  394. $result = Db::name('user_auth')->where(['user_id' => $this->auth->id, 'status' => $user_auth['status']])->setField($edit_data);
  395. if (!$result) {
  396. Db::rollback();
  397. $this->error('查询认证结果失败2');
  398. }
  399. //修改用户信息
  400. $rs = Db::name('user')->where(['id' => $this->auth->id])->setField('real_status', $edit_data['status']);
  401. if (!$rs) {
  402. Db::rollback();
  403. $this->error('查询认证结果失败3');
  404. }
  405. if ($edit_data['status'] == 1) { //通过
  406. //tag任务赠送金币
  407. //真人认证奖励
  408. $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,6);
  409. if($task_rs === false){
  410. Db::rollback();
  411. $this->error('完成任务赠送奖励失败');
  412. }
  413. //系统消息
  414. $msg_id = \app\common\model\Message::addMessage($this->auth->id,'真人认证','真人认证已经审核通过');
  415. } else {
  416. //系统消息
  417. $msg_id = \app\common\model\Message::addMessage($this->auth->id,'真人认证','真人认证审核不通过');
  418. }
  419. Db::commit();
  420. $this->success($msg);
  421. }
  422. //真人认证后修改头像
  423. public function editrealavatar() {
  424. if ($this->auth->real_status != 1) {
  425. $this->error('尚未通过真人认证');
  426. }
  427. $avatar = input('avatar', '', 'trim'); //头像地址
  428. if ($avatar === '') {
  429. $this->error('参数缺失');
  430. }
  431. $avatar = one_domain_image($avatar);
  432. $now_avatar = one_domain_image($this->auth->avatar);
  433. if ($avatar == $now_avatar) {
  434. $this->error('头像未改变');
  435. }
  436. //腾讯云人脸识别
  437. $auit_result = $this->face_tencent($now_avatar, $avatar); //1通过 0拒绝
  438. if ($auit_result != 1) {
  439. $this->success('提示', ['code' => 2]);
  440. }
  441. $data['avatar'] = $avatar;
  442. $user_result = Db::name('user')->where(['id' => $this->auth->id])->setField($data);
  443. if (!$user_result) {
  444. $this->error('修改失败');
  445. }
  446. $this->success('修改成功');
  447. }
  448. //真人认证后修改头像并取消真人认证
  449. public function editrealavatarcancelauit() {
  450. if ($this->auth->real_status != 1) {
  451. $this->error('尚未通过真人认证');
  452. }
  453. $avatar = input('avatar', '', 'trim'); //头像地址
  454. if ($avatar === '') {
  455. $this->error('参数缺失');
  456. }
  457. $avatar = one_domain_image($avatar);
  458. $now_avatar = one_domain_image($this->auth->avatar);
  459. if ($avatar == $now_avatar) {
  460. $this->error('头像未改变');
  461. }
  462. $data['avatar'] = $avatar;
  463. $data['real_status'] = -1;
  464. //开启事务
  465. Db::startTrans();
  466. $user_result = Db::name('user')->where(['id' => $this->auth->id])->setField($data);
  467. if (!$user_result) {
  468. Db::rollback();
  469. $this->error('修改失败');
  470. }
  471. $user_auth_result = Db::name('user_auth')->where(['user_id' => $this->auth->id])->delete();
  472. if (!$user_auth_result) {
  473. Db::rollback();
  474. $this->error('修改失败');
  475. }
  476. Db::commit();
  477. $this->success('修改成功');
  478. }
  479. //腾讯云人脸识别
  480. public function face_tencent($urla = '', $urlb = '') {
  481. // require_once 'vendor/autoload.php';
  482. try {
  483. // 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey,此处还需注意密钥对的保密
  484. // 密钥可前往https://console.cloud.tencent.com/cam/capi网站进行获取
  485. $config = config('tencent_realauth');
  486. $cred = new Credential($config['SecretId'], $config['SecretKey']);
  487. // 实例化一个http选项,可选的,没有特殊需求可以跳过
  488. $httpProfile = new HttpProfile();
  489. $httpProfile->setEndpoint("iai.tencentcloudapi.com");
  490. // 实例化一个client选项,可选的,没有特殊需求可以跳过
  491. $clientProfile = new ClientProfile();
  492. $clientProfile->setHttpProfile($httpProfile);
  493. // 实例化要请求产品的client对象,clientProfile是可选的
  494. $client = new IaiClient($cred, "ap-beijing", $clientProfile);
  495. // 实例化一个请求对象,每个接口都会对应一个request对象
  496. $req = new CompareFaceRequest();
  497. $params = array(
  498. "UrlA" => $urla,
  499. "UrlB" => $urlb,
  500. "FaceModelVersion" => "3.0"
  501. );
  502. $req->fromJsonString(json_encode($params));
  503. // 返回的resp是一个CompareFaceResponse的实例,与请求对象对应
  504. $resp = $client->CompareFace($req);
  505. // 输出json格式的字符串回包
  506. // print_r($resp->toJsonString());
  507. $result = json_decode($resp->toJsonString(), true);
  508. //3.0版本误识率千分之一对应分数为40分,误识率万分之一对应分数为50分,误识率十万分之一对应分数为60分。 一般超过50分则可认定为同一人。
  509. if (isset($result['Score']) && $result['Score'] >= 60) {
  510. return 1; //通过
  511. } else {
  512. return 0;
  513. }
  514. }
  515. catch(TencentCloudSDKException $e) {
  516. // echo $e;
  517. return 0;
  518. }
  519. }
  520. }