I am running an app live at domain.com
and wants to continue the development on localhost for which I setup local.domain.com
to 127.0.0.1
in my hosts file. Everything works fine other than PHP is not able to pick up session when the login is handled by the JS SDK.
My JS code:
FB.login(func开发者_如何学运维tion(response) {
if (response.session) {
if (response.perms) {
// user is logged in and granted some permissions.
// perms is a comma separated list of granted permissions
init();
} else {
// user is logged in, but did not grant any permissions, eh?
showMessage( "Error!", "You haven't grant proper permissions!" );
}
} else {
// user is not logged in
showMessage( "Error!", "You are not logged in" );
}
}, {perms:'email'});
After the login from JS, I do an AJAX call where PHP can't pick up session information. My PHP code:
$session = $facebook->getSession(); // this is null somehow
The same code works fine, live on domain.com
but on localhost, the $session
on PHP side
is null. Any ideas?
Did you try using localhost
as your application domain name?
You should probably create 2 apps, one for your local testing and another one for your live code.
精彩评论