p_ysk/app/common/controller/ApiController.php

21 lines
625 B
PHP

<?php
namespace app\common\controller;
use app\exception\MyBusinessException;
use support\exception\BusinessException;
class ApiController
{
protected static $token = 'kiy7s194DXKSpP8CJtRpnYn5r5HrHQTf';
public function __construct()
{
$request = request();
$get_token = $request->header('token');
// 基类
if(empty($get_token)) {
throw new MyBusinessException('参数错误', 500);
}
if($get_token != self::$token) {
throw new MyBusinessException('参数错误', 500);
}
}
}