Facebook Integration......

Need help with an engine or coding not on the list? Need help with a game or the website and forums here? Direct all questions here.
Post Reply
User avatar
Ravinos
Posts: 281
Joined: Tue Sep 15, 2009 4:14 pm

Facebook Integration......

Post by Ravinos »

5 days of pounding my head on the desk trying to figure out how to integrate facebook with a website I'm working on and I have finally caved. The facebook developer's website is so poorly designed it's stupid. I'm not looking to do the social bullshit facebook has to offer, I just want people to be able to sign up for my site with their facebook info and login.

I put up the Javascript SDK registration along with the login example and they work like they are supposed to. I just cannot figure out how to then take data from the facebook login and put it in my users database.

My idea would be to have facebook supply their name, email and a few other bits of info and then ask them to give me a new username associated with their facebook account on their first login. People can register directly or use facebook to log in. If a facebook user already has a standalone account it will merge the two together.

Has anyone had any experience with this system yet? Even something as simple as the persons name put into a PHP variable would be a big step up from where I am currently.
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Facebook Integration......

Post by Jackolantern »

Is login integration accessible through the Facebook SDK? While I am not familiar with the SDK, it seems like this could be a dangerous thing for them to offer. If it is an offered feature, maybe they have a ton of red-tape around it to protect the Facebook user's info?
The indelible lord of tl;dr
User avatar
Ravinos
Posts: 281
Joined: Tue Sep 15, 2009 4:14 pm

Re: Facebook Integration......

Post by Ravinos »

It's how all the facebook connect websites work including the games that offer both FB and external login. Right now after take a step back from it I've figured out how to register/login and pull the users first and last name. However I cannot figure out how to the pull the email. The email is the biggest issue I have with it right now. That is the key data I need to prevent people from double registering and if they do, it will merge the facebook and external login into the same user profile.
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Facebook Integration......

Post by Jackolantern »

Hmm..interesting. I wonder why I have not seen more websites that allow FB login then. I have only seen the huge websites like YouTube that allow it.

As far as the issue, is there a forum you could ask on? The lack of decent documentation has been the thing that has kept me from digging into it.
The indelible lord of tl;dr
User avatar
Ravinos
Posts: 281
Joined: Tue Sep 15, 2009 4:14 pm

Re: Facebook Integration......

Post by Ravinos »

If I can't get this to work I have no idea how in the hell I'd ever do a game on facebook. There just aren't any good tutorials out there.

Looking at it they are switching heavily into Javascript now. Is there an easy way to send java variables to php?
pretender5552
Posts: 127
Joined: Mon Jan 03, 2011 5:38 am

Re: Facebook Integration......

Post by pretender5552 »

User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Facebook Integration......

Post by Jackolantern »

The only way to send Javascript variables to the web server (and, in turn, to PHP) is through AJAX. And the easiest way to handle AJAX is with jQuery.

And I have heard before that the lack of FB tutorials is due to how fast the FB API changes. In the beginning a few authors were trying to keep books up-to-date but eventually realized it was going to be as impossible as keeping a WoW Addon book updated.
The indelible lord of tl;dr
User avatar
Ravinos
Posts: 281
Joined: Tue Sep 15, 2009 4:14 pm

Re: Facebook Integration......

Post by Ravinos »

Pretender thanks for the link. Facebook doesn't allow you to really do the PHP/FBML way anymore. They disabled the key features I need to get my stuff to work right. I know nothing of javascript or ajax. Unfortunately working 50 hours a week doesn't leave much time for "the learning" process. I found a few good tutorials for the FBML way but none of them end up working due to Facebook hating everyone.

Looks like I'm stuck again. Back to the drawing board I guess.....I enclosed the script I'm "forced" to work with. If anyone can show me how to convert the javascript response "response[0].uid" to php that would be awesome.

<script>
FB.api(
{
method: 'fql.query',
query: 'SELECT name,uid FROM user WHERE uid=5526183'
},
function(response) {
alert('Name is ' + response[0].name + response[0].uid);
}
);
</script>
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Facebook Integration......

Post by Jackolantern »

You could learn jQuery which can cut months off of the learning curve of Javascript. Here is the W3Schools tutorial, which, while it doesn't teach you near everything, will teach you the basics quickly. Of major interest is jQuery AJAX, which will allow you to send values back to the web server in just 2 or 3 lines of code, versus 25 - 40 for regular Javascript (once you count adding a robust timing system, it would be about 30 lines or more). Check out the AJAX section in that tutorial to see how to easily send values back to the web server.

And yeah, FBML is what most of the tutorials and books deal with. I didn't know they changed over to all JS.
The indelible lord of tl;dr
User avatar
Ravinos
Posts: 281
Joined: Tue Sep 15, 2009 4:14 pm

Re: Facebook Integration......

Post by Ravinos »

I actually took a step back from the code. Had dinner while rethinking my method of getting the info.....I think I figured it out. Since the facebook login feature creates a cookie for whoever logs in I just have it add a session variable as well for that person. With that cookie it contains the users name, email and facebook user id. So I just get that info during log in and boom the variable gets sent to the server to see if they have another account. If the check comes back empty it makes a new user with their name, email, and facebookid, assigns them a site userid and boom. After they land on their page they will be prompted to create a site specific password in case they want to log in without facebook.

I need to spend more time with it but it seems to be working so far.
Post Reply

Return to “Advanced Help and Support”