Facebook 应用程序:FB 活动仅在第一次时有效
我使用以下代码来订阅 Facebook 登录和注销事件。
FB.Event.subscribe('auth.logout', function(response) {
RefreshPageOnFBStatusChange(response);
});
FB.Event.subscribe('auth.login', function(response) {
RefreshPageOnFBStatusChange(response);
});
function RefreshPageOnFBStatusChange(response)
{
alert(response.status);
}
我想在用户登录或注销时将用户重定向到不同的页面。我在这里使用的函数仅在实际页面加载期间被调用,之后绝不会被调用。我的页面上有一个类似 Facebook 的 Facebook 共享和直播插件。当我登录和注销直播时,没有任何反应。帮助!
I'm using the following code to subscribe to fb login and logout events.
FB.Event.subscribe('auth.logout', function(response) {
RefreshPageOnFBStatusChange(response);
});
FB.Event.subscribe('auth.login', function(response) {
RefreshPageOnFBStatusChange(response);
});
function RefreshPageOnFBStatusChange(response)
{
alert(response.status);
}
I want to redirect users to different pages when they are logged in or logged out. The function I'm using here gets called only during the actual page load, and never after that. I have a fb-like, fb-share and live stream plugin on a page. When I login and logout of live stream, nothing happens. Help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请修改您的问题并提供所有FB相关代码。
这可能会回答你的问题:
Facebook FB.Event.subscribe 事件不触发:(
Please modify your question and provide all FB-related code.
This may answer you question:
Facebook FB.Event.subscribe event does not fire:(
对于用户状态,您可以使用 if(FB._userStatus == "connected"){} 来检查用户是否登录,对于注销和登录,您可以使用 if(FB._userStatus == "connected"){} 来检查用户是否登录。登录您可以使用以下简单的代码
FB.logout(function(response) { window.location = redriect_uri;
});
For User Status you can use if(FB._userStatus == "connected"){} to check user is login or not And for Logout & login you can use following simple code
FB.logout(function(response) { window.location = redriect_uri;
});
当您使用实时聊天插件时,这些事件似乎不会触发,因为它有自己的处理登录和注销的方式。为了解决这个问题,我必须做的是设置 5 秒的超时并调用执行 FB.GetLoginStatus 的 JavaScript 函数,然后根据情况刷新页面。这不是最好的方法,但我别无选择。
It seems like these events don't fire when you use the live chat plugin because it has its own way of handling the login and logout. What I had to do to solve this problem was to set a timeout of 5 seconds and call a javascript function that did a FB.GetLoginStatus, and based on what it was I would refresh the page. Not the best way of doing it, but I was left with no choice.