getRequestToken(); /* Tokenをセッションに格納 */ $_SESSION['oauth_request_token'] = $token = $tok['oauth_token']; $_SESSION['oauth_request_token_secret'] = $tok['oauth_token_secret']; $_SESSION['oauth_state'] = "start"; /* authorization URL を生成*/ $request_link = $to->getAuthorizeURL($token); $content = 'Click on the link to go to twitter to authorize your account.'; $content .= '
'.$request_link.''; header("Location: $request_link"); break; case 'returned': ///* もし access tokens がすでにセットされている場合は、 API call にいく if ($_SESSION['oauth_access_token'] === NULL && $_SESSION['oauth_access_token_secret'] === NULL) { $to = new TwitterOAuth($consumer_key, $consumer_secret, $_SESSION['oauth_request_token'], $_SESSION['oauth_request_token_secret']); $tok = $to->getAccessToken(); ///* Tokenをセッションに格納 $_SESSION['oauth_access_token'] = $tok['oauth_token']; $_SESSION['oauth_access_token_secret'] = $tok['oauth_token_secret']; } // Twitter名をセッションに格納 $_SESSION['username'] = $tok["screen_name"]; //Topページへ戻る header("Location: /"); } ?>