Example #1
0
 /**
  * make OAuth Authorize URL
  *
  * @param string $callback_url
  * @param bool   $use_cookie
  * @return string authorize_url
  */
 public function getAuthorizeUrl($callback_url = null, $use_cookie = false)
 {
     // -- check Cookie
     $cookie_key = $this->_getAuthorizeUrlCookieName();
     if ($use_cookie && $this->Cookie->read($cookie_key)) {
         return $this->Cookie->read($cookie_key);
     }
     // -- request token
     $token = $this->DataSource->oauth_request_token($callback_url);
     $url = $this->DataSource->oauth_authorize();
     // -- set cookie
     if ($use_cookie) {
         $this->Cookie->write($cookie_key, $url, true, self::OAUTH_URL_COOKIE_EXPIRE);
     }
     return $url;
 }
 function testOauthAccessToken()
 {
     return $this->skipIf(true);
     $requestToken = $this->TestSource->oauth_request_token(Router::url('/openlist/twitter_kit/callback', true));
     $authUrl = $this->TestSource->oauth_authorize();
     debug($authUrl);
     $url = 'http://localhost/openlist/twitter_kit/callback?oauth_token=ly4DCCcq4gddZMuFNp7vbJgQiSna7Hoq4Xd7CuGOOk&oauth_verifier=Nvnw5OnMkVFv5S4tjLvKLLmsMbDyKEM92HeEILC6u7g';
     $oauth_token = 'ly4DCCcq4gddZMuFNp7vbJgQiSna7Hoq4Xd7CuGOOk';
     $oauth_verifier = 'Nvnw5OnMkVFv5S4tjLvKLLmsMbDyKEM92HeEILC6u7g';
     $token = $this->TestSource->oauth_access_token($oauth_token, $oauth_verifier);
     if (is_string($token)) {
         $this->assertEqual('Invalid / expired Token', $token);
     } else {
         $this->assertTrue(is_array($token));
         $this->assertTrue(is_string($token['oauth_token']));
         $this->assertTrue(is_string($token['oauth_token_secret']));
         $this->assertTrue(is_string($token['user_id']));
         $this->assertTrue(is_string($token['screen_name']));
         $this->assertEqual($token['oauth_token'], $this->TestSource->oauth_token);
         $this->assertEqual($token['oauth_token_secret'], $this->TestSource->oauth_token_secret);
     }
 }
Example #3
0
 /**
  * make OAuth Authorize URL
  *
  * @param AppModel $model
  * @param string $callback_url
  * @return string authorize_url
  */
 public function twitterAuthorizeUrl($model, $callback_url = null)
 {
     $token = $this->DataSource->oauth_request_token($callback_url);
     return $this->DataSource->oauth_authorize();
 }