views:

74

answers:

2

I have a website based game that has login accounts that I want to integrate into facebook (not facebook connect, I want to use an iframe canvas page).

My question is how can I authenticate a user and how can I check if a user is coming from facebook or directly from the site.

I have been playing around with require_login() using the PHP library. My main fear is how can I authenticate that the GET parameters from facebook are indeed from facebook? If I can do that then I can store their facebook session id and Uid in a session as login credentials.

My other worry is that the GET variable may get passed as a reffer to an external link.

Finally... I find in some browsers that with require_login() that it breaks out of the iframe and gets into an eternal look continually adding additional authtoken's to the URL.

Hope someone can help

A: 

Yes you can create a app that works independently as well as facebook app. For the facebook you will have to use the facebook's iframe method to work under facebook.

Sarfraz
I realised this... I have already got that far, I am more interested in the authentication side of things, but thanks
Mark
Sorry I didn't see the link... I'll have a read
Mark
@Mark: no problem dude, thank you :)
Sarfraz
I am trying out the code, but I get an issue with $facebook->api_client->users_isAppAdded() ...the wiki says its been depreciated... any ideas?
Mark
@Mark: no idea man, they keep changing the things fast, it is always hard to keep up to date with fast changing facebook api, so i would suggest you to google about it. thanks
Sarfraz
A: 

You can verify the request comes from Facebook by verifying the signature in the same way that Facebook checks that API requests come from your application. With the PHP client library you can use the validate_fb_params() method of the Facebook class to do this automatically.

Bear in mind that session key's are temporary so the user will keep needing to authenticate with Facebook through your application otherwise the key expires within the hour. You may also run into a 3rd party cookie issue with Safari if you're hoping to store the session key in a cookie, and you'll need a compact privacy for quite a few other browser/privacy setting combinations as well. Something like:

<?php
header('P3P: CP="CAO PSA OUR"');
?>

in an include would do it.

And yes: the session key may be passed to external sites as in the referrer properties. It's just one of the security flaws that the platform currently has. The only way around that is either to redirect all external clicks through a handler which removes the referrer, or redirect on page load to strip the fb_sig_ss parameter out.

Karl B
This looks like a good alternative to the third party cookie issuehttp://www.foobots.net/breakouts.html
Mark

related questions