/** * 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'); }
/** * @throws \Workflow\Exception\PocketException */ public function appAction() { $oauth = UserOauth::find(["user_id = :user_id: and access_token <> ''", 'bind' => ['user_id' => $this->current_user->id]]); $app = []; foreach ($oauth as $item) { $app[$item->app] = 'auth'; } $pushbullet = new Pushbullet(''); $pushbullet->setConfig($this->config); $pock = new Pocket(''); $pock->setConfig($this->config); $request_token = $pock->requestToken(); $this->view->setVar('pushbullet_authorize_uri', $pushbullet->authorizeUrl()); $this->view->setVar('pocket_authorize_uri', $pock->authorizeUrl($request_token)); $this->view->setVar('app', $app); }