示例#1
0
 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');
 }
示例#2
0
 /**
  * @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);
 }