/** * Console方法: php index.php wechat accessToken [--renew] * 获取微信服务号的access token */ public function accessTokenAction() { $request = $this->getRequest(); if (!$request instanceof ConsoleRequest) { throw new \RuntimeException('You can only use this action from a console!'); } $renew = $request->getParam('renew'); //$verbose = $request->getParam('verbose') || $request->getParam('v'); $token = $this->wechat->getAccessToken($renew); return "TOKEN:{$token} \n"; }