[ 'class' => \yii\filters\VerbFilter::className(), 'actions' => [ 'token' => ['POST'], ], ], ]); } /** * 获取accessToken * @author: libingke */ public function actionToken() { $model = new AuthForm(); $model->setScenario('access_token'); $model->load(['AuthForm' => Yii::$app->request->post()]); $data = []; if ($model->validate()) { $data = $model->getAccessToken(); } else { $model->handleError(); } return [ 'code' => 200, 'message' => Yii::t('error', 200), 'data' => $data ]; } }