Skip to main content

Use Of Facebook And Twitter API For Login


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 SCRIPT              


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.

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) 
);

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.

<?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());
?>

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

Popular posts from this blog

Network Topologies (Tutorial-4)

Topology refers to the way in which the network of computers is connected. The choice of topology is dependent upon--- Type and number of equipment being used  Planned applications and rate of data transfers  Required response times  Cost Types of Network Topologies Physical Topology: Physical topology defines how devices are connected to the network through the actual cables that transmit data(physical structure of the network)  Logical Topology: Logical Topology (also referred to as Signal Topology) is a network computing term used to describe the arrangement of devices on a network and how they communicate with one another.

Cisco Hierarchical Model

Cisco Hierarchical Model Defined by Cisco to simplify the design, implementation, and maintenance of responsive, scalable, reliable, and cost-effective networks. The 3 layers are logical and not physical – there may be many devices in a single layer, or a single device may perform the functions of 2 layers, eg: core and distribution. The Cisco Hierarchical Model

Eden: PHP Library To Get Things Easy For PHP Developer

Eden is PHP Library designed for helping developers in their rapid development work. In Our most of the project we have to integrate our developed website or application with most of  the social networking websites like Google, Facebook, Twitter, yahoo etc. so what we do is we integrate libraries of different websites differently Although We could make the code reusable but still if the websites increases then confusion will also increases. Adding different libraries form different sources add more complexity to your project and ends up to be hard to maintain. Eden simply a set of reusable components, that works with any PHP framework and CMS. Eden makes code logical and readable with dead simple syntax. Eden Will work With Most Of Web services including Amazon Web service Facebook Foursquare Google twitter tumbler Paypal Yahoo You could Download the File From  Eden Official Website  and Can use this will just a simply including this...