El login funciona bien, pero si cierro y abro el browser pierde la session y no mantiene el logueo, o no encuentro como detectarlo.
el codigo es algo asi
Código PHP:
<?php
// facebook
define('FACEBOOK_APP_ID', 'xxxx');
define('FACEBOOK_SECRET', 'xxxxxxxxxxxxxxxxxxxx');
// Create our Application instance.
$facebook = new Facebook_Facebook(array(
'appId' => FACEBOOK_APP_ID,
'secret' => FACEBOOK_SECRET,
'cookie' => true
));
/*$session_key = md5($facebook->api_client->session_key);
session_id($session_key);
session_start();*/
$session = $facebook->getSession();
$me = null;
// Session based API call.
if ($session) {
echo "logueado";
try {
$uid = $facebook->getUser();
$me = $facebook->api('/me');
$me2 = $facebook->api('/me/friends');
} catch (FacebookApiException $e) {
error_log($e);
}
} else {
echo "deslogueado";
}
?>
<div style="text-align:left;width:500px;height:80px;border-bottom:1px solid #000;" >
<span style="font-weight:bold;">Ingresar usando su cuenta de Facebook</span>
<br/><br/>
<div id="fb-root"></div>
<fb:login-button perms="email,user_birthday,publish_stream,publish_checkins,offline_access,read_friendlists,friends_likes,user_likes,user_about_me,friends_about_me,friends_activities,friends_interests"></fb:login-button>
</div>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId: "<?php echo FACEBOOK_APP_ID;?>",
status: true,
cookie: true,
xfbml: true
});
FB.Event.subscribe('auth.login', function(response) {
if (response.session) {
var facebook_id = response.session['uid'];
alert ("uid: "+facebook_id);
} else {
// The user has logged out, and the cookie has been cleared
}
});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol + '//connect.facebook.net/es_LA/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>