public function init() { parent::init(); $this->module = \kepco\Module::getInstance(); $this->client = new \GuzzleHttp\Client(['base_uri' => 'http://srm.kepco.net/', 'cookies' => true, 'allow_redirects' => false, 'headers' => ['User-Agent' => 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36', 'Cookie' => $this->cookie, 'X-CSRF-TOKEN' => $this->token]]); $this->sub = \Yii::createObject(['class' => \kepco\Redis::className(), 'hostname' => $this->module->redis_server]); }
public function publish($channel, $message) { if ($this->redis === null) { $this->redis = \Yii::createObject(['class' => \kepco\Redis::className(), 'hostname' => $this->redis_server]); } $this->redis->publish($channel, $message); }
public function actionAuto() { $request = \Yii::$app->request; if ($request->post()) { $pub = \Yii::createObject(['class' => Redis::className(), 'hostname' => $this->module->redis_server]); $pub->set('kepco.cookie', $request->post('cookie')); $pub->set('kepco.token', $request->post('token')); $pub->publish('kepco-login', ['cookie' => $request->post('cookie'), 'token' => $request->post('token')]); return 'cookie: ' . $request->post('cookie') . ' token: ' . $request->post('token'); } return ''; }