|
@@ -11,6 +11,7 @@ namespace Modules\Admin\Http\Controllers\Api;
|
|
|
use App\Enum\ApiEnum;
|
|
|
use App\Http\Controllers\Controller;
|
|
|
use Illuminate\Http\Request;
|
|
|
+use Illuminate\Support\Facades\Input;
|
|
|
use Modules\Admin\Entities\User;
|
|
|
use Modules\Admin\Http\Requests\TokenRequest;
|
|
|
use Modules\Staff\Entities\Staff;
|
|
@@ -85,4 +86,59 @@ class TokenController extends Controller
|
|
|
$proxy->request->add($params);
|
|
|
return app()->handle($proxy);
|
|
|
}
|
|
|
+
|
|
|
+ public function checkToken(Request $request){
|
|
|
+ $ts = Input::get('ts', '');
|
|
|
+ $loginid = Input::get('loginid', '');
|
|
|
+ $token = Input::get('token', '');
|
|
|
+ $salt = 'aqgltx@2022';
|
|
|
+
|
|
|
+ $year = substr($ts, 0, 4);
|
|
|
+ $month = substr($ts, 4, 2);
|
|
|
+ $day = substr($ts, 6, 2);
|
|
|
+ $hour = substr($ts, 8, 2);
|
|
|
+ $minute = substr($ts, 10, 2);
|
|
|
+ $second = substr($ts, 12, 2);
|
|
|
+ $formattedDateString = "$year-$month-$day $hour:$minute:$second";
|
|
|
+ $timestamp = strtotime($formattedDateString);
|
|
|
+
|
|
|
+// if(time() - $timestamp > 5){
|
|
|
+// return $this->error(1003, '已超时');
|
|
|
+// }
|
|
|
+
|
|
|
+ $md5 = md5($loginid.'|'.$ts.'|'.$salt);
|
|
|
+ if($md5 != $token){
|
|
|
+ return $this->error(1003, '验证失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ $data['username'] = 'admin';
|
|
|
+ $data['password'] = 'Zhks123456+';
|
|
|
+
|
|
|
+ $result = $this->httpRequest(env('VIDEO_SYSTEM_URL').'/api/oauth/token','post',$data);
|
|
|
+
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function httpRequest($url, $format = 'get', $data = null){
|
|
|
+ //设置头信息
|
|
|
+ $headerArray =array("Content-type:application/json;","Accept:application/json");
|
|
|
+ $curl=curl_init();
|
|
|
+ curl_setopt($curl, CURLOPT_URL, $url);
|
|
|
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
|
|
|
+ curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
|
|
|
+ if ($format == 'post') {
|
|
|
+ //post传值设置post传参
|
|
|
+ curl_setopt($curl, CURLOPT_POST, 1);
|
|
|
+ if ($data) {
|
|
|
+ $data = json_encode($data);
|
|
|
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
|
|
+ curl_setopt($curl,CURLOPT_HTTPHEADER,$headerArray);
|
|
|
+ $data=json_decode(curl_exec($curl), true);
|
|
|
+ curl_close($curl);
|
|
|
+ //返回接口返回数据
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
}
|