TwitterOAuth::getAuthorizeURL PHP Method

getAuthorizeURL() public method

Get the authorize URL
public getAuthorizeURL ( $token, $sign_in_with_twitter = TRUE )
    function getAuthorizeURL($token, $sign_in_with_twitter = TRUE)
    {
        if (is_array($token)) {
            $token = $token['oauth_token'];
        }
        if (empty($sign_in_with_twitter)) {
            return $this->authorizeURL() . "?oauth_token={$token}";
        } else {
            return $this->authenticateURL() . "?oauth_token={$token}";
        }
    }

Usage Example

Example #1
0
 protected function _loginAction()
 {
     $option = $this->_getProviderOption();
     // セッションにアクセストークンがなかったらloginページに飛ぶ
     // サインインしていてもログイン状態でなければSESSIONを消す
     $pengin =& Pengin::getInstance();
     if ($pengin->cms->isUser() == false) {
         unset($_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
     }
     if (isset($_SESSION['oauth_token']) == true and isset($_SESSION['oauth_token_secret']) == true) {
         if ($_SESSION['oauth_token'] === NULL && $_SESSION['oauth_token_secret'] === NULL) {
             $tokenExist = false;
         } else {
             $tokenExist = true;
         }
     } else {
         $tokenExist = false;
     }
     if ($tokenExist == false) {
         // OAuthオブジェクト生成
         $to = new TwitterOAuth($option['key'], $option['secret']);
         // callbackURLを指定してRequest tokenを取得
         $tok = $to->getRequestToken($this->connect);
         // セッションに保存
         $_SESSION['request_token'] = $token = $tok['oauth_token'];
         $_SESSION['request_token_secret'] = $tok['oauth_token_secret'];
         // サインインするためのURLを取得
         $url = $to->getAuthorizeURL($token);
         header("location:" . $url);
         die;
     } else {
         //サインインしていればヘッダーを出力
         //include("user_header.php");
     }
 }
All Usage Examples Of TwitterOAuth::getAuthorizeURL