[英]Twitter API v1.1. Abraham library: no redirection after signing in
I am using the abraham library to sign in with twitter on my website. 我正在使用亚伯拉罕图书馆在我的网站上通过Twitter登录。
I have done many tutorials and I don't understand why the callback url is never called. 我已经完成了许多教程,但我不明白为什么从未调用过回调URL。
The file "login.php" correctly displays the twitter authentication form. 文件“ login.php”正确显示Twitter身份验证表单。 Clicking on "Sign in" only redirects to https://api.twitter.com/oauth/authenticate .
单击“登录”仅重定向到https://api.twitter.com/oauth/authenticate 。 However when I click on "Cancel" it redirects to the specified callback file.
但是,当我单击“取消”时,它将重定向到指定的回调文件。
I gave a callback url to the method "getRequestToken" and set the same url in the application settings on the twitter dev website. 我为方法“ getRequestToken”提供了一个回调URL,并在twitter dev网站上的应用程序设置中设置了相同的URL。 I have set the application access as "Read only" and checked "Allow this application to be used to Sign in with Twitter".
我已将应用程序访问权限设置为“只读”,并选中了“允许该应用程序用于通过Twitter登录”。
This is my files: 这是我的文件:
login.php: login.php:
<?php
session_start();
include_once("twitter-config.php");
include_once("lib/twitteroauth-master/twitteroauth/twitteroauth.php");
$connection = new TwitterOAuth($CONSUMER_KEY, $CONSUMER_SECRET);
$request_token = $connection->getRequestToken($OAUTH_CALLBACK); //get Request Token
if( $request_token)
{
$token = $request_token['oauth_token'];
$_SESSION['request_token'] = $token ;
$_SESSION['request_token_secret'] = $request_token['oauth_token_secret'];
switch ($connection->http_code)
{
case 200:
$url = $connection->getAuthorizeURL($token);
//redirect to Twitter .
header('Location: ' . $url);
break;
default:
print_r($connection->http_info);
echo "<br/>Connection with twitter Failed<br/><br/> Date du serveur:" . date("M d Y H:i:s", time()) . " <br/> Date de Twitter: " . $connection->http_header['date'];
break;
}
}
else //error receiving request token
{
echo "Error Receiving Request Token";
}
?>
twitter-config.php: twitter-config.php:
<?php
/**
* @file
* A single location to store configuration.
*/
$CONSUMER_KEY = 'XXXXXXX';
$CONSUMER_SECRET = 'XXXXXXX';
$OAUTH_CALLBACK = 'https://www.xxxxx.com/preprod/users/twitter-signin/oauth.php';
?>
Thanks in advance for any help. 在此先感谢您的帮助。
这是Twitter开发人员的问题: https : //dev.twitter.com/discussions/21599
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.