|
@@ -0,0 +1,60 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace app\api\controller;
|
|
|
+
|
|
|
+use app\common\controller\Api;
|
|
|
+use think\Db;
|
|
|
+/**
|
|
|
+ * 人脸核身
|
|
|
+ */
|
|
|
+class Renlian extends Api
|
|
|
+{
|
|
|
+ protected $noNeedLogin = [];
|
|
|
+ protected $noNeedRight = ['*'];
|
|
|
+
|
|
|
+ public function access_token(){
|
|
|
+ $config = config('renlian');
|
|
|
+ $appid = $config['appid'];
|
|
|
+ $secret = $config['secret'];
|
|
|
+
|
|
|
+ $url = 'https://miniprogram-kyc.tencentcloudapi.com/api/oauth2/access_token?app_id='.$appid.'&secret='.$secret.'&grant_type=client_credential&version=1.0.0';
|
|
|
+ $result = curl_get($url);
|
|
|
+
|
|
|
+ $token = '';
|
|
|
+ if($result){
|
|
|
+ $result = json_decode($result,true);
|
|
|
+ if($result['code'] == 0 && isset($result['access_token'])){
|
|
|
+ $token = $result['access_token'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $token;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function nonce_ticket(){
|
|
|
+ $config = config('renlian');
|
|
|
+ $appid = $config['appid'];
|
|
|
+ $secret = $config['secret'];
|
|
|
+
|
|
|
+ $token = $this->access_token();
|
|
|
+ $url = 'https://miniprogram-kyc.tencentcloudapi.com/api/oauth2/api_ticket?app_id='.$appid.'&access_token='.$token.'&type=NONCE&version=1.0.0&user_id='.$this->auth->id;
|
|
|
+
|
|
|
+ $tickets = '';
|
|
|
+ $result = curl_get($url);
|
|
|
+// dump($result);
|
|
|
+ if($result){
|
|
|
+ $result = json_decode($result,true);
|
|
|
+ if($result['code'] == 0 && isset($result['tickets'][0]['value'])){
|
|
|
+ $tickets = $result['tickets'][0]['value'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success('success',$tickets);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public function sdksign(){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|