YII 接口 用户鉴权 问题

   开发项目过程中,有的时候必须需要传一个用户的token值(用户唯一标识ID), 才给返回json数据,不传的话,就提示用户鉴权失败。而有的时候不用传。对于这个问题,不需要传token值的方法体需要写在一个数组中。类似于这样:

class PostController extends BaseApiController{

protected $_method_not_check = [ //把函数体放在此处,该接口的参数就不用必须再传token值也可以返回json数据了
'actionIndex',
'actionWebCommunity',
...
];

public function actionIndex(){
dosomething..
if(...)
return $this->_result_success(...);
else
return $this->_result_error(...);
   }
}
原文地址:https://www.cnblogs.com/wangshuazi/p/9630808.html