Hello,
I am using the abraham library.
I have done many tutorials and I don’t understand why the callback url is never called.
The file “login.php” correctly displays the twitter authentication form. Clicking on “Sign in” only redirects to https://api.twitter.com/oauth/authenticate.
However when I click on “Cancel” it redirects to the 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. I have set the application access as “Read only” and checked “Allow this application to be used to Sign in with Twitter”.
This is my files:
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 "
Connection with twitter Failed
Date du serveur:" . date("M d Y H:i:s", time()) . "
Date de Twitter: " . $connection->http_header['date'];
break;
}
}
else //error receiving request token
{
echo "Error Receiving Request Token";
}
?>
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.