Our app having a problem with authentication, we unable to get authentication window. I am posting code here. Please lemme know, where’s the problem. We are getting error connecting to twitter message. Attaching image.
$link='/createb';
define('CONSUMER_KEY', '*******');
define('CONSUMER_SECRET', '********');
define('OAUTH_CALLBACK', $link);
\\Include config file and twitter PHP Library
include_once("config.php");
include_once("twitter/twitteroauth.php");
//echo $_GET['request'].'anutest';
//twitter
if(isset($_GET['request']))
{
\\Fresh authentication
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
$request_token = $connection->getRequestToken(OAUTH_CALLBACK);
\\Received token info from twitter
$_SESSION['token'] = $request_token['oauth_token'];
$_SESSION['token_secret'] = $request_token['oauth_token_secret'];
//$_SESSION['token'] = " ************ ";
//$_SESSION['token_secret'] = " ******** ";
echo "<pre>" ;
print_r($connection);
\\Any value other than 200 is failure, so continue only if http code is 200
if($connection->http_code == '200')
{
\\redirect user to twitter
$twitter_url = $connection->getAuthorizeURL($request_token['oauth_token']);
header('Location: ' . $twitter_url);
}else{
die("error connecting to twitter! try again later!");
}
}
I don’t know PHP that well to tell straight away what’s wrong but this is a working example of the Login flow in PHP TwitterOAuth PHP Library for the Twitter REST API
1 Like
Thanks for ur reply, I will have a look at what you suggested.
What is the http code and what is the error response being returned from twitter?
We are not getting tokens while authentication, http code is 403, error response “error connecting to twitter,try again later”. Ours is a https connection. Attaching http code and error screenshots. Please have a look. Thank you.
system
Closed
#6
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.