检查用户是否也是使用JS的粉丝

时间:2011-12-01 22:33:35

标签: facebook

我是FB应用程序开发的初学者,我正在试图弄清楚如何检查当前浏览我的页面的用户是否也是粉丝。

我有一个appID,pageID,想使用JS,但不知道我在哪里误会

这是代码

<%@ Page Language="c#" AutoEventWireup="false" Inherits="test" Codebehind="test.aspx.cs" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>


    <script src="http://connect.facebook.net/en_US/all.js" type="text/javascript"></script>

    <script type="text/javascript">

FB.init({ 
    appId:'validappID', 
    cookie:false, 
    status:true, 
    xfbml:true
});

    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');
            }
        }
    });

    </script>


    </body>
</html>

1 个答案:

答案 0 :(得分:1)

我认为你在FB.init()调用中缺少channelUrl。此外,我将更改代码以加载SDK Async,如下所述:https://developers.facebook.com/docs/reference/javascript/,一旦您执行了这些操作,请告诉我您是否还有问题。