I would like to develop an external website using Facebook Connect instead of an own login and registration process.
On the first page (index.php) I have the following code for the login button:
<fb:login-button v="2" size="large" autologoutlink="false" onlogin="window.location='/index.php'">Connect with Facebook</fb:login-button>
For authentification, I use this library for PHP.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="content-language" content="de" />
<meta http-equiv="content-script-type" content="text/javascript" />
<meta http-equiv="content-style-type" content="text/css" />
</head>
<body>
<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/de_DE" type="text/javascript"></script><script type="text/javascript">FB.init("XYZ");</script>
<?php
error_reporting(E_ALL);
include_once '/XYZ/facebook.php';
include_once 'lib.php';
include_once 'config.php';
$facebook = new Facebook($api_key, $secret);
$user = $facebook->require_login();
$loggedin = FALSE;
if (isset($user)) {
if ($user != '') {
echo '<p>Hello <fb:name firstnameonly="true" uid="'.$user.'" useyou="false" /></p>';
echo '<p><a href="#" onclick="javascript:FB.Connect.logoutAndRedirect(\'/\'); return false">Log out</a></p>';
$loggedin = TRUE;
}
}
if ($loggedin == FALSE) {
echo '<p><fb:login-button onlogin="window.location=\'/\'"></fb:login-button></p>';
}
?>
</body>
</html>
Unfortunately, it doesn't work yet. What is wrong here?
When I want to access this page, I'm redirected to http://www.facebook.com/login.php?api_key=XYZ&v=1.0&next=XYZ where I have to log in. Then, being logged in to Facebook, I'm redirected again. This time, I get to https://login.facebook.com/login.php?auth_token=XYZ