public function actionSave() { \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $accountId = $this->getAccountId(); if (empty($accountId)) { return ['code' => 400, 'msg' => 'missing accountId']; } $body = Yii::$app->request->getRawBody(); $query = json_decode($body); if (empty($query)) { return ['code' => 400, 'msg' => 'bad request']; } if (!isset($query->token)) { return ['code' => 400, 'msg' => 'missing token']; } $query->accountId = new \MongoId($accountId); $user = PushUser::saveToken($query); return ['code' => 200, 'msg' => 'ok']; }