Login with Facebook and Google.
Wall Script
Wall Script
Monday, October 22, 2012

Login with Facebook and Google.

Introducing the new FGlogin commercial edition, an OAuth login system for your website with Facebook and Google. FGLogin is very quick and powerful, sure this helps you to increase your web project registrations. It's definitely a must have login system for every PHP based web projects. Hardly it will take 5 mins for installation.

Login with Facebook and Google.


Download Script     Live Demo

Database
Users table database design.
CREATE TABLE IF NOT EXISTS `users`
(
id INT(11) NOT NULL AUTO_INCREMENT,
email VARCHAR(200) ,
name VARCHAR(200) ,
first_name VARCHAR(200) ,
last_name VARCHAR(200) ,
gender VARCHAR(10) ,
birthday VARCHAR(20) ,
location VARCHAR(200) ,
hometown VARCHAR(200) ,
bio TEXT,
relationship VARCHAR(30) ,
timezone VARCHAR(10) ,
provider VARCHAR(10) ,
provider_id INT(30) ,
picture TEXT,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;

The script contains three folders called facebook_lib,google_lib and images with PHP files.
facebook_lib //Facebook OAUTH library
-- config.php //Facebook app configuration file.
google_lib //Google OAUTH library
-- config.php //Google app configuration file.
images
db.php //Database connection
FGlogin.php //Class
facebook_login.php //Facebook Login
google_login.php //Google Login
index.php
home.php
logout.php

How it Works

Facebook & Google Authentication Flowchart


Installation
In this script just you have to modify three file.

db.php
Database configuration file, modify MySQL server details.
<?php
$mysql_hostname = "localhost";
$mysql_user = "username";
$mysql_password = "password";
$mysql_database = "databasename";
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Could not connect database");
mysql_select_db($mysql_database, $bd) or die("Could not select database");
?>

Application setup details click here.

Facebook Configuration facebook_lib/config.php
You have to create a application. Facebook will provide you app id and app secret id, just replace in the following code.
fbconfig.php
<?php
$facebook_appid='App ID';
$facebook_app_secret='App Secret';
$facebook = new Facebook(array(
'appId' => $facebook_appid,
'secret' => $facebook_app_secret,
));
?>


Google Configuration google_lib/config.php
You can find this in google_lib folder, here you have to configure application OAuth keys, Consumer keys and redirection callback URL.
// OAuth2 Settings, you can get these keys at https://code.google.com/apis/console Step 6 keys 
'oauth2_client_id' => 'App Client ID',
'oauth2_client_secret' => 'App Client Secret',
'oauth2_redirect_uri' => 'http://yoursite.com/gplus/index.php',

// OAuth1 Settings Step 3  keys.
'oauth_consumer_key' => 'OAuth Consumer Key',
'oauth_consumer_secret' => 'OAuth Consumer Secret',


web notification

51 comments:

  1. Nice Post as always...i am also php developer and enjoyying your every post...

    ReplyDelete
  2. i love this tutorial. but "FGlogin commercial edition"?

    ReplyDelete
  3. Hey How is this different from your previous tutorial on Facebook login and G Login

    ReplyDelete
  4. Thanks Srinivas..It is always great to learn new things from You !!!

    ReplyDelete
  5. ! great ... but what about "FGlogin commercial edition" 15$ ?!?!

    ReplyDelete
  6. Nice one bro. I follow your tutorials every time
    but why it is commercial bro :(

    ReplyDelete
  7. Awesome Thanks for sharing this tutorial.

    ReplyDelete
  8. i want know too,how is this different from your previous tutorial on Facebook login and G Login

    ReplyDelete
  9. Win Exciting and Cool Prizes Everyday @ www.2vin.com, Everyone can win by answering simple questions.Earn points for referring your friends and exchange your points for cool gifts.

    ReplyDelete
  10. neither is LinkedIn's

    ReplyDelete
  11. Thats a nice script but iam implementing users module for my script after its succesfully worked out then i will definitely buy your script i liked it.

    ReplyDelete
  12. Do you enable Session or cookie in this tutorial in order to authenticate the user the rest of the application?

    ReplyDelete
  13. now this solves all the problems and makes it easy for the developers nice article.

    ReplyDelete
  14. This could help me get few more traffic and simply steps thanks bro

    ReplyDelete
  15. Hi,
    I need change the name of the users table, could you tell me where are all occurrences?
    thanks

    ReplyDelete
  16. Thanks for your post. On my next project I will and an FB and Google login. This here helps me alot.

    ReplyDelete
  17. thanks for sharing this information..

    ReplyDelete
  18. Thanks for sharing this article
    helps me alot

    ReplyDelete
  19. Need help .. doesnt work work for me : /

    copy & past Code to the FTP .. cretaed Table, db and FB-settings done, kicked out "include("google_login.php");" - bcoz i only wanne use the facebook-login.

    after hit "facebook login" nothing happen - no redirect to "home.php" .. only the url changes to "/?state=b61.....d14e1&code=AQDtI... a-#_=_"

    No error .. just no movement

    ReplyDelete
  20. Thanks for this wonderful information. Very helpful

    ReplyDelete
  21. {
    "error": {
    "message": "Error validating application. Invalid application ID.",
    "type": "OAuthException",
    "code": 101
    }
    }

    ReplyDelete
  22. I suggest this change in
    google_lib/auth/apiOAuth2.php

    change line 37 from
    public $approvalPrompt = 'force';
    to
    public $approvalPrompt = 'auto';

    That way auth url stops asking the user for permission every time.

    ReplyDelete
  23. Hi!
    I have purchased it and it works great as it comes.
    Nevertheless, I tried to modify it to work with the mysqli API instead of mysql API (I read is obsolete and deprecated), and I haven't managed to make it work.
    It is possible? And if so, do I have to change more things than the "API calls"?

    Thanks in advance!

    Adrián

    ReplyDelete
  24. I am new to php...so how do i restrict page to login in case the user comes back to my site the next time...thanks for the tutorial...

    ReplyDelete
  25. i have error OauthLogin/facebook_login.php?error_code=901&error_message=This+app+is+in+sandbox+mode.++Edit+the+app+configuration+at+http%3A%2F%2Fdevelopers.facebook.com%2Fapps+to+make+the+app+publicly+visible.&state=fc69ee507ac7bf318298a942e244ec8b#_=_

    ReplyDelete
  26. nice blog finally i got good1

    ReplyDelete
  27. Can you update the Screenshot for google app creation on this page http://www.oauthlogin.com/ because https://developers.google.com/accounts/docs/RegistrationForWebAppsAuto?csw=1 this page has a different look now.

    ReplyDelete
  28. Paypal not accept payment with in India, so how can i buy this script ?

    ReplyDelete
  29. Hi Shree,
    You can send a mail to [email protected] for Bank Details

    ReplyDelete
  30. What is the diffrence between OAuth Login and FG Login?

    And what happens when Fb changes their policy as they recently did, will the script be updated?

    ReplyDelete
  31. Tamade sir You Are Always Awesome........

    ReplyDelete

mailxengine Youtueb channel
Make in India
X