如果用户没有登录到Facebook,则FB.getLoginStatus不会触发 [英] FB.getLoginStatus doesn't fire if the user is not logged in to Facebook
问题描述
我正在Facebook上整合Facebook应用程序,并尝试获取用户的FB会话。据我所知,一个常见的使用情况如下。
- 调用
FB.init() code>
- 调用
FB.getLoginStatus
给它一个适当的回调。
我运行了以下代码(应用程序ID)。
< div ID = FB-根 >< / DIV>
< script src =http://connect.facebook.net/en_US/all.js>< / script>
< script type =text / javascript>
<! -
函数init(){
FB.init({
appId:'9999999999999',
status:true,/ /检查登录状态
cookie:true,//启用Cookie以允许服务器访问会话
xfbml:true,//解析XFBML
channelUrl:'http://127.0.0.1 :8888 / channel.html',//自定义渠道
oauth:true //启用OAuth
});
alert('去调用FB.getLoginStatus');
FB.getLoginStatus(function(response){
alert('whoo hoo !!! getLoginStatus called the callback');
});
}
init();
// - >
< / script>
如果用户已经在同一浏览器会话中登录到Facebook,那么一切都按预期方式运行 - 返回人口稠密的 _response.authResponse _
。但是,如果用户没有登录到Facebook,则不会触发回调。检查浏览器网络日志,我看到Facebook返回以下响应(请求从 http://www.facebook.com/dialog/oauth
?)。
应用程序错误:获取您请求的应用程序的数据时出现问题。申请可能无效,或可能有暂时的毛刺。请稍后再试。
我在Chrome和Firefox(Mac)上检查过。
更新
我要感谢所有回复的人。
Ben 的评论有答案。
$ b $感谢本 - 你救了我很多沮丧。
原因是最近的一个 bug ,这只影响沙箱模式。我关闭了沙箱模式,它的工作就像一个魅力。
I am working on a Facebook application which is integrated with Facebook and am trying to get the user's FB session. As far as I understand, a common usage scenario is as follows.
- call
FB.init()
- call
FB.getLoginStatus
giving it an appropriate callback.
I ran the following code (the application id).
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
<!--
function init(){
FB.init({
appId : '9999999999999',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
channelUrl : 'http://127.0.0.1:8888/channel.html', // custom channel
oauth : true // enable OAuth
});
alert('going to call FB.getLoginStatus ');
FB.getLoginStatus(function(response) {
alert('whoo hoo!!! getLoginStatus called the callback');
});
}
init();
//-->
</script>
If the user is already logged in to Facebook in the same browser session then everything works as expected - returning the populated _response.authResponse_
. However, if the user is not logged in to Facebook the callback is not triggered at all. Checking the browsers network log, I see that Facebook returns the following response (request from http://www.facebook.com/dialog/oauth
?).
Application Error: There was a problem getting data for the application you requested. The application may not be valid, or there may be a temporary glitch. Please try again later.
I checked this on Chrome and Firefox (Mac).
Update
I would like to thank everyone who responded.
Ben's comment had the answer.
Thanks Ben - you saved me lots of frustration.
The cause is a recent bug which only affects sandbox mode. I switched off sandbox mode, and it worked like a charm.
这篇关于如果用户没有登录到Facebook,则FB.getLoginStatus不会触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!