Php Twitter登录:重定向无效
我正在尝试使用TwitterPHP库使用TwitterAPI实现登录。一切似乎都很好。我为用户获得Twitter登录屏幕。根据代码,我得到了Php Twitter登录:重定向无效,php,codeigniter,twitter,twitter-oauth,Php,Codeigniter,Twitter,Twitter Oauth,我正在尝试使用TwitterPHP库使用TwitterAPI实现登录。一切似乎都很好。我为用户获得Twitter登录屏幕。根据代码,我得到了$twitterouth->http_codeAs200。但它一直将页面重定向到同一个Twitter登录屏幕。 这是我的密码: function loginTwitter() { // The TwitterOAuth instance $twitteroauth = new TwitterOAuth('xxx',
$twitterouth->http_code
As200
。但它一直将页面重定向到同一个Twitter登录屏幕。
这是我的密码:
function loginTwitter()
{
// The TwitterOAuth instance
$twitteroauth = new TwitterOAuth('xxx', 'xxxxx');
// Requesting authentication tokens, the parameter is the URL we will be redirected to
$request_token = $twitteroauth->getRequestToken('http://localhost/testsaav/socialAuth/twitterAuth');
// Saving them into the session
$_SESSION['oauth_token'] = $request_token['oauth_token'];
$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
// If everything goes well..
if($twitteroauth->http_code==200){
// Let's generate the URL and redirect
$url = $twitteroauth->getAuthorizeURL($request_token['oauth_token']);
header('Location: '. $url);
} else {
// It's a bad idea to kill the script, but we've got to know when there's an error.
die('Something wrong happened.');
}
}
Twitter API版本已从1更改为1.1。请将1替换为1.1,但您需要新版本的身份验证类及其密钥。