Example #1
0
 /**
  * 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');
 }