/** * Pushbullet redirect uri * * @return \Phalcon\Http\ResponseInterface */ public function pushbulletAction() { $code = $this->request->get('code'); try { $pushbullet = new Pushbullet(''); $pushbullet->setConfig($this->config); $token = $pushbullet->getToken($code); } catch (Exception $e) { $this->flashSession->error($e->getMessage()); return $this->response->redirect('user/app'); } $pushbullet_oauth = UserOauth::findFirst(["user_id = :user_id: and app = 'pushbullet'", 'bind' => ['user_id' => $this->current_user->id]]); if ($pushbullet_oauth) { $pushbullet_oauth->access_token = $token; $pushbullet_oauth->save(); // active UserActive::record('oauth-edit', $this->current_user->id); } else { $oauth = new UserOauth(); $oauth->user_id = $this->current_user->id; $oauth->app = 'pushbullet'; $oauth->access_token = $token; $oauth->create(); // active UserActive::record('oauth-create', $this->current_user->id); } return $this->response->redirect('user/app'); }