FB.INIT不强制登录甚至状态:true js sdk [英] FB.INIT not forcing login even with status:true js sdk

查看:109
本文介绍了FB.INIT不强制登录甚至状态:true js sdk的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序允许用户使用Facebook请求对话发送请求。

My app allows users to send requests using Facebook Requests Dialogue.

我运行init,如下所示:

I run the init as follow:

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
    appId: '193078857407882',
    status: true,
    cookie: true,
     xfbml: false,
       });
</script>

从我在文档中了解到的status:true应该检查用户是否登录到Facebook。

From what I understand in the documentation the 'status: true' is supposed to check if the user is logged in to facebook.

然而,在我的应用程序中,当用户没有登录时,只会显示以下错误消息:

However in my app when the user is not logged in it just shows the following error message:

An error occurred with hbg. Please try again later.

如何强制应用程序检查用户是否登录,如果不登录?

How can I force the application to check if the user is logged in and if not to log in?

Rails 3.0.7,Ruby 1.9.2,Js SDK

Rails 3.0.7, Ruby 1.9.2, Js SDK

推荐答案

p>您可以通过调用FB.getLoginStatus来检查登录状态

You can check login status by calling FB.getLoginStatus

    FB.getLoginStatus(function(response) {
        if (response.authResponse) {
        // logged in and connected user
        } else {
            FB.login(function(res) {
                if (res.authResponse) {
                    // user logged in
                } else {
                    // user cancelled login
                }
            });
        }
    });

这篇关于FB.INIT不强制登录甚至状态:true js sdk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆