阅读背景:

tp5.1最新的类库使用规则

来源:互联网 
<?php
namespace app\api\controller;

use think\Controller;
use think\Request;
use app\api\controller\Send;
use app\api\controller\Oauth;

class Api
{	
	use Send;
	public function init()
	{	
		//所有ajax请求的options预请求都会直接返回200,如果需要单独针对某个类中的方法,可以在路由规则中进行配置
		if($this->request->isOptions()){

			return self::returnMsg(200,'success');
		}
		//配置不要鉴权的方法白名单
		if(!in_array($this->request->controller().'/'.$this->request->action().'/'.strtolower($this->request->method()),config('allow_method'))){
			//授权处理
			$oauth = app('app\api\controller\Oauth');   //tp5.1容器,直接绑定类到容器进行实例化
    		return $this->clientInfo = $oauth->authenticate();;
		}

	}
}<?php
namespace app\api\controller;

use 



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: