Login with Facebook and Twitter using PHP

By ongraph
November 5, 2014 | 2233 Views

Latest Industry insights to keep you updated on the latest happenings.

Facebook and Twitter have the wide network and popularity in the world now a days.

Both facebook and twitter are offering oAuth support which makes it easy to connect through other sites with facebook and twitter.
The below is simple implementation steps to integrate facebook and twitter login.


Step 1: Database

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



Step 2: You have to download and setup facebook sdk from below link:-




Facebook OAuth library
Config files

— functions.php
— databaseconfig.php  // for Database connection
— facebookconfig.php  //for Facebook API connection




You have to download and setup twitter sdk from below link:-



Twitter OAUTH library
Config files
— functions.php
— databaseconfig.php // for Database connection
— twitterconfig.php //for Twitter API connection




Step 3: Facebook Setup


You have to create an application with Facebook and it will provide you app id and app secret id, just modify following code
facebookconfig.php( or facebook config file)



Step 4: Twitter Setup

You have to create a application.Like Facebook, Twitter provides you consumer key and consumer secret key using these modify following code.
Twitterconfig.php( or twitter config file)


Step 5: databaseconfig.php


Database configuration file.



Step 6: Index.php


To modify your web project existing login or index pages, just use following code.



Step 7: login_facebook.php




Step 8: login_twitter.php



Step 9: fetchTwitterData.php



Step 10: Home.php


Monthly industry insights to keep you updated on latest happenings

Follow us on Twitter
Follow us on Facebook
Follow us on Linkedin