Facebook Javascript, How to detect if user is a fan of my facebook page? While on my site?

不问归期 提交于 2019-12-06 02:09:19

The FB.getLoginStatus check to see if the user is connected to your application .. not to facebook.

But when the user is not connected to your application, the .status property can tell you the reason of the fail (if the user is not logged-in at all, or just to your app).

So the structure you should use is

FB.getLoginStatus(function(response) {
        if(response.session) {
            alert('connected to Application');
        } else {
            // no user session available, someone you dont know
            if(response.status == "notConnected") {
                // But user is logged into facebook
                alert("Not connected to Application, but is logged in to Facebook");
            } else {
                // User is not logged into facebook
                  alert('Not logged in to facebook');
            }
        }
    });

But you cannot access the ID of a user that has not authorized your Application.
Not through Javascript API.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!