When users come to my site they have the option to log in through facebook. If they are logged in to facebook, and hit the fb login button, it will show all the appropriate logged in dialog. However, if you log out of facebook (either through my site or through facebook itself) and then try to log in through my site again, it will bring you to facebook to sign in, then bring you back to my site. The url changes from x.net/index.php to x.net/index.php?state=... bunch of letters / numbers, but then doesn t return logged in dialog. Hit the button once again after that, and the page refreshes with a different (but similar) url, and returns all the logged in dialog.
任何关于如何解决这一问题的想法?
在这里,我使用的法典是连接手法,并获取标识和标志。
//facebook application
$fbconfig[ appid ] = "myAppId";
$fbconfig[ secret ] = "myAppSecret";
$fbconfig[ baseurl ] = "http://myNeatSite.net/index.php";
if (isset($_GET[ request_ids ])){
//user comes from invitation
//track them if you need
}
$user = null; //facebook user uid
try{
include_once "facebook.php";
}
catch(Exception $o){
error_log($o);
}
// Create our Application instance.
$facebook = new Facebook(array(
appId => $fbconfig[ appid ],
secret => $fbconfig[ secret ],
cookie => true,
));
//Facebook Authentication part
$user = $facebook->getUser();
$loginUrl = $facebook->getLoginUrl(
array(
scope => email,publish_stream ,
redirect_uri => $fbconfig[ baseurl ]
)
);
$logoutUrl = $facebook->getLogoutUrl();
if ($user) {
try {
// Proceed knowing you have a logged in user who s authenticated.
$user_profile = $facebook->api( /me );
} catch (FacebookApiException $e) {
$user = null;
}
}