I am trying to integrate my existing php site with Facebook Login functionality. I currently have a simple login registration username, password and email for activation and their details are stored in a MYSQL database. I want to add additional login access for Facebook users. I am worried about how i will be able to integrate my current login access with the new facebook access. Principal on my mind is that all my pages require users to be logged in and i use cookies to store session variables like nickname which i use to build content on my pages.
I am confused by the many approaches I have researched on the web, some are now sadly obsolete and others seem to be half solutions. These three keep re-occurring.
A) Login.php, Register.php and fbReg.php The login.php and register.php appear when logged in using fb login/register to create a session and pass authentication to the fbReg.php but it just stops there with a blank screen after the page is redirected.
(a snippet from the Register.php)
<script type="text/javascript">
FB.init({appId: '<?php echo $fb_app_id; ?>', status: true,
cookie: true, xfbml: true});
<?php
if ($errors == 0) {
?>
$('#form_hidden').hide();
<?php } else { ?>
checkInput('username');
checkInput('email');
checkInput('lastname');
checkInput('firstname');
checkInput('password');
checkInput('password2');
<?php } ?>
</script>
B) Legacy Connect Auth http://developers.facebook.com/docs/authentication/connect_auth/ Using the above link I constructed some test scripts just to see if the authentication would work. Fortunately on my site I have third party ads or webframes but followed the steps to the letter building a interstitial_page and redirected page from my main login page. However I keep getting a null session.
(snippet from the php login page)
$api_key = "YOUR_API_KEY";
$interstitial_page = "YOUR_SECURE_URL"; //URL with no 3rd party apps
$url='http://www.facebook.com/login.php?api_key=' . $api_key
. '&session_version=3&next=' . urlencode($interstitial_page)
. '&v=1.0&return_session=1&fbconnect=1'
. '&cancel_url=' . urlencode($interstitial_page);
echo "Welcome to the Old Auth flow";
echo "<p>";
echo("<a href='" . $url . "'>"
. "<img src='http://static.ak.facebook.com/images/"
. "devsite/facebook_login.gif'></a>");
C) OAuth 2.0 protocol http://developers.facebook.com/docs/authentication/ when I use this again using the following script:
https://www.facebook.com/dialog/oauth?
client_id=YOUR_APP_ID&redirect_uri=YOUR_URL
I have tried and failed to use this to capture User info for my new facebook site users and store it to MySQL database then integrate this authenticated facebook access with the 'normal' web access user session since that has assocaiated session variables which are used the the user experience.
Any help would be appreciated, im struggling at the moment.
Thanks Michael
i get a blank screen on the fbReg.php