Hello friends this is a best tutorial for a web developer.Here i am using twitter and Facebook API's.Which helps the developer in logging with Facebook and twitter into their website.
This tutorial is useful because our visitor don't want to waste time in filling the sign up form.We know that everyone is having their Account in Facebook and twitter.
So we helps the user to login into website with his Facebook
and twitter login id and password.
Download the script from above downloading link. After that its time to create the Database.
Create the database name as you want.Now we have to create the table.Using the below SQL query your table is created.
(
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)
);
By this you have successfully create the database and table with columns id,email,oauth_uid,oauth_provider,username,twitter_oauth_token,twitter_oauth_token_secret.
FACEBOOK SETUP:
To start with facebook setup first you have to create a Facebook Application
When you create a facebook application,facebook will provide you App id,App Secret id.
Now you have to modify the fccconfig.php files which comes under config.php
<?php
define('APP_ID', 'Facebook APP ID');
define('APP_SECRET', 'Facebook Secret ID');
?>
TWITTER SETUP:
Create a Twitter Application.After that twitter will provide you consumer key and consumer secret key.
Now modify the twconfig.php and fill the consumer key and secret key.
<?php
define('YOUR_CONSUMER_KEY', 'Twitter Key');
define('YOUR_CONSUMER_SECRET', 'Twitter Secret Key');
?>
DATABASE CONFIGRATION:
Now configure dbconfig.php file and fill all the fields.
Now configure dbconfig.php file and fill all the fields.
<?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) ordie(mysql_error());
$database = mysql_select_db(DB_DATABASE) or die(mysql_error());
?>
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) ordie(mysql_error());
$database = mysql_select_db(DB_DATABASE) or die(mysql_error());
?>
Lgintwitter.php
Replace youw website name..
$request_token = $twitteroauth->getRequestToken('http://yourwebsite.com/getTwitterData.php');
index.php
if you want to modify the index page then only modify this page.
<?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
<a href="?login&oauth_provider=twitter">Twitter_Login</a>
<a href="?login&oauth_provider=facebook">Facebook_Login</a>
Thanks friends hope you like my tutorial if you are having any query or question the comment below. i am here to help you..
Comments
Post a Comment
your Comment is sent for moderation, Thankyou