protected function execute(array $arguments) { if (isset($arguments[0]) && ($user_id = (int) $GLOBALS['user_id'])) { $oauth = \UserOauth::findFirst(["user_id = :user_id: and app='pushbullet'", 'bind' => ['user_id' => $user_id]]); if ($oauth) { $token = $oauth->access_token; $pushbullet = new Pushbullet($token); $pushbullet->pushNote('', $arguments[0]); } return ''; } throw new InvalidArgumentException('strings invalid'); }
protected function execute(array $arguments) { if (isset($arguments[0]) && ($user_id = (int) $GLOBALS['user_id'])) { $oauth = \UserOauth::findFirst(["user_id = :user_id: and app='pocket'", 'bind' => ['user_id' => $user_id]]); if ($oauth) { global $config; $token = $oauth->access_token; $pocket = new Pocket($token); $pocket->setConfig($config); $pocket->addItem($arguments[0]); } return ''; } throw new InvalidArgumentException('strings invalid'); }
/** * Pocket * * @return \Phalcon\Http\ResponseInterface * @throws \Workflow\Exception\PocketException */ public function pocketAction() { $request_token = $this->request->get('request_token'); $pocket = new \Workflow\Api\Pocket(''); $pocket->setConfig($this->config); $access_token = $pocket->authorizeCode($request_token); $pocket_oauth = UserOauth::findFirst(["user_id = :user_id: and app = 'pocket'", 'bind' => ['user_id' => $this->current_user->id]]); if ($pocket_oauth) { $pocket_oauth->access_token = $access_token; $pocket_oauth->save(); // active UserActive::record('oauth-edit', $this->current_user->id); } else { $oauth = new UserOauth(); $oauth->user_id = $this->current_user->id; $oauth->app = 'pocket'; $oauth->access_token = $access_token; $oauth->create(); // active UserActive::record('oauth-create', $this->current_user->id); } return $this->response->redirect('user/app'); }