I keep trolling the internet for tutorials on how to do this to no avail. I followed this
on getting it set up, but it doesn’t go through how to save the information received. Actually it doesn’t go through if there is and information received.
Thanks so much!!
more information.
What I want to do is have a FB login to my site. If it is a fist time user, I want his ID, name, and email saved to a database. If it’s an old user, then I need his ID to check it against the database.
heres my current code:
<html>
<head>
<title>My Facebook Login Page</title>
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '223157403572264',
status : true,
cookie : true,
xfbml : true,
oauth : true,
});
};
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
<div class="fb-login-button" data-scope="email,user_checkins">
Login with Facebook
</div>
</body>
edit- more information
edit2- my code
Just after the
initof your Facebook object, you can “subscribe” to events, like saying “when my user is just logged in, i want to do that…”For further informations about that, you can look to this topic !
But what you really need is, i think, to use the
FB.apito call for specific informations about the user. Once he’s logged in you can call this function like this :You make a call to retrieve information about
/me(= the current logged in user), then you have your callback function which you can use to send your data with an AJAX call or anything else to some server script that will store it to your Database, but you know how to do this part I think 🙂For more informations sabout the
FB.apiyour should check this documentation