Use your Facebook account to sign into other sites and see what your friends are doing across the web. Facebook and Twitter have become large in the social network world and both networks offering oAuth support. Use your Facebook account to sign into other sites and see what your friends are doing across the web. Visitors will be far more likely to become members and participate on your site if all they have to do is login with their existing Facebook account.

“Sign in with Twitter” is the pattern of authentication that allows users to connect their Twitter account with third-party services in as little as one click. It utilizes OAuth and although the flow is very similar, the authorization URL and workflow differs slightly as described below.

9lession developed a system to login with Twitter and Facebook. Nowadays web users not interested to filling the big registration forms. This script helps you to avoid registration forms, It’s is very useful and simple to integrate.

The code is in PHP which can easily migrate in other like asp.net. Below you will get the –

1) Source code download for Login with Facebook and Twitter

2) Demo for Login with Facebook and Twitter

3) Implementation steps in details for Login with Facebook and Twitter

Twitter-Facebook-login
————————————————-

Download the source code and view live demo :

Login with Facebook and Twitter using PHP Download Source

Login with Facebook and Twitter using PHP Demo

Download the updated (new) source code and view new live demo:

Login with Facebook and Twitter using PHP Source Code Updated

 

Login With Facebook and Twitter New Live Demo

 

 

Database
Sample database users table columns id, email, oauth_uid, oauth_provider and username.

CREATE TABLE users
(
id INT PRIMARY KEY AUTO_INCREMENT,
email VARCHAR(70), 
oauth_uid VARCHAR(200),
oauth_provider VARCHAR(200),
username VARCHAR(100), 
twitter_oauth_token VARCHAR(200), 
twitter_oauth_token_secret VARCHAR(200) 
);

 

The tutorial contains three folders called facebook,twitter and config with PHP files.
facebook //Facebook OAUTH library
twitter //Twitter OAUTH library
config
— functions.php 
— dbconfig.php //Database connection
— fbconfig.php //Facebook API connection
— twconfig.php //Twitter API connection
index.php
home.php
login-twitter.php
login-facebook.php
getTwitterData.php

Facebook Setup

You have to create a application. Facebook will provide you app id and app secret id, just modify following code
fcconfig.php

< ?php
define('APP_ID', 'Facebook APP ID');
define('APP_SECRET', 'Facebook Secret ID');
?>

Twitter Setup

Create a twitter application click here. Some like Facebook Twitter provide you consumer key amd consumer secret key using these modify following code.
twconfig.php

< ?php
define('YOUR_CONSUMER_KEY', 'Twitter Key');
define('YOUR_CONSUMER_SECRET', 'Twitter Secret Key');
?>

dbconfig.php
Database configuration file.

< ?php
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'User Name');
define('DB_PASSWORD', 'Password');
define('DB_DATABASE', 'DATABASE');
$connection = mysql_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD) or die(mysql_error());
$database = mysql_select_db(DB_DATABASE) or die(mysql_error());
?>

login-twitter.php
In root directory find out the below line at login-twitter.php code and replaceyourwebsite.

$request_token = $twitteroauth->getRequestToken('http://yourwebsite.com/getTwitterData.php');

index.php
If you want to modify your web project existing login or index pages, just use following code.

< ?php
session_start();
if (isset($_SESSION['id'])) {
// Redirection to login page twitter or facebook
header("location: home.php");
}
if (array_key_exists("login", $_GET)) 
{
$oauth_provider = $_GET['oauth_provider'];
if ($oauth_provider == 'twitter')
{
header("Location: login-twitter.php");
}
else if ($oauth_provider == 'facebook')
 {
header("Location: login-facebook.php");
}
}
?>
//HTML Code
Twitter_Login
Facebook_Login

 
Try Updated new demo and source code which is based on the latest Login with Facebook and Twitter API.

If any queries about How to do Login with Facebook and Twitter please comment here.