Im trying to develop a new FB App, however it seems they have changed their ways once again.
Im looking for the correct way to authenticate a fb user to my app, and retrieve the userid.
I have found the following method:
// Authenticate the user
session_start();
if(isset($_REQUEST["code"])) {
$code = $_REQUEST["code"];
}
if(empty($code) && !isset($_REQUEST['error'])) {
$_SESSION['state'] = md5(uniqid(rand(), TRUE)); //CSRF protection
$dialog_url = 'https://www.facebook.com/dialog/oauth?'
. 'client_id=' . $app_id
. '&redirect_uri=' . urlencode($app_url)
. '&state=' . $_SESSION['state']
. '&scope=publish_actions';
print('');
exit;
My question is now.
Do i not need the facebook SDK at all ? Since its not needed here im thinking its not needed at all.
Would the correct way be to put this code in top of all my documents, thereby constantly making sure the user is authorized ?
Thank you
Maybe you are looking for this
It will require something like this: