Twitter is a large social network and they provide Oauth Support.Signin with twitter Oauth is used to avoid form filling for registration and easily signin using twitter account.
This tutorial contains the following files.
1.index.php
2.config.php
3.process.php
and library files provided by twitter.
Please share your comments and feebback.Thanks.Please subscribe my updates via email.
This tutorial contains the following files.
1.index.php
2.config.php
3.process.php
and library files provided by twitter.
Config.php
<?php
define('CONSUMER_KEY', 'XXXXXXXX'); //Replace With your key
define('CONSUMER_SECRET', 'XXXXXXXX');//Replace With your CONSUMER SECRET
define('OAUTH_CALLBACK', 'XXXXXXXX');//Replace With your Callback url
?>
define('CONSUMER_KEY', 'XXXXXXXX'); //Replace With your key
define('CONSUMER_SECRET', 'XXXXXXXX');//Replace With your CONSUMER SECRET
define('OAUTH_CALLBACK', 'XXXXXXXX');//Replace With your Callback url
?>
Login Button
<?php
echo '<a href="process.php"><img src="images/sign-in-with-twitter-l.png" width="151" height="24" border="0" /></a>';
?>
echo '<a href="process.php"><img src="images/sign-in-with-twitter-l.png" width="151" height="24" border="0" /></a>';
?>
Welcome Message for User
<?php
$Username = $_SESSION['request_vars']['screen_name'];//Twitter username
$twitterid = $_SESSION['request_vars']['user_id']; //Twitter Account Id
$oauth_token = $_SESSION['request_vars']['oauth_token']; //Twiiter Oauth token
$oauth_token_secret = $_SESSION['request_vars']['oauth_token_secret']; //Twitter Secret
//Show welcome message
echo '<div class="welcome_txt">Welcome <strong>'.$Username.'</strong> <a href="index.php?reset=1" style="float:right">Logout</a>!</div>';
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $oauth_token, $oauth_token_secret); ?>
$Username = $_SESSION['request_vars']['screen_name'];//Twitter username
$twitterid = $_SESSION['request_vars']['user_id']; //Twitter Account Id
$oauth_token = $_SESSION['request_vars']['oauth_token']; //Twiiter Oauth token
$oauth_token_secret = $_SESSION['request_vars']['oauth_token_secret']; //Twitter Secret
//Show welcome message
echo '<div class="welcome_txt">Welcome <strong>'.$Username.'</strong> <a href="index.php?reset=1" style="float:right">Logout</a>!</div>';
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $oauth_token, $oauth_token_secret); ?>