[web] Facebook game login questions

Started by
0 comments, last by cagecrawler 12 years, 10 months ago
Hello,

I'm in the process of converting a PHP browser game to run in a Facebook application. The only issue I'm running into is regarding user access/logging in. The way it works with most Facebook games is your account is tied to your game so when you load an application you're automatically logged into the game assuming you're logged into Facebook. I'm not too sure how to proceed here, how it works with the regular game is a user logs in via a form and after successful authentication a session is created.


I'm assuming a similar system can be implemented here as well although I don't know how Facebook communicates with the application and I can't find any PHP related tutorial that is up to date. To sum it up, I'm stumped.


Does anyone have any ideas?
Advertisement
Assuming you're wanting to keep the same accounts, you need to link a Facebook account with a game account. When the page is loaded through Facebook, you use their API to confirm the login and then check your application to see if the person has a game account. If they don't, prompt them to create one (or link an existing account to Facebook) else populate the session with the relevant data as you would normally. The only extra data you will (probably, I've not got round to implementing this on my game yet) need to store is the Facebook account ID to link with the game account. Using this, you can actually still allow a user to log on outside of Facebook using the existing method, although whether to allow this depends on your level of interaction with Facebook.

The Facebook developer documentation gives a good explanation of how you can authenticate users as well as examples of flows and code.

This topic is closed to new replies.

Advertisement