2011-11-22 59 views
0

我有一个javascript函数,它使用fb.login来检索用户信息并检查用户是否喜欢我的fb页面。 fb.login会导致用户必须点击登录按钮的弹出窗口。如果用户喜欢我的网页,我需要先创建一个cookie,然后将其重定向到主应用程序:如何检查用户是否喜欢页面没有fb.login弹出

function checkUser() { 
    var page_id = "my id goes here"; // 
    FB.login(function (response) { 
     if (response.authResponse) { 
      console.log('Welcome! Fetching your information.... '); 
      FB.api('/me', function (response) { 
       var fql_query = "SELECT uid FROM page_fan WHERE page_id = " + page_id + "and uid=" + response.id; 
       var the_query = FB.Data.query(fql_query); 
       the_query.wait(function (rows) { 

        if (rows.length == 1 && rows[0].uid == response.id) { 
         //$("#container_like").show();/ 
         //set cookie 
         document.cookie = "fbId=" + response.id; 


         window.location = "/kisses.aspx"; 


        } else { 
         $("#likepageholder").show(); 
         //$("#container_notlike").show(); 
         //window.location = "/kisses.aspx"; 
         //and here you could get the content for a non liker in ajax... 
        } 
       }); 

      }); 
     } else { 
      console.log('User cancelled login or did not fully authorize.'); 
     } 
    }); 
} 

如果使用左右一个的FB.login办法做到这一点?

回答

0

没有。不幸的是,你需要用户登录(并授予你应用程序的基本权限(基于你在FB.init中使用的appId)以查询用户的喜好。

这就是说,它看起来像你的代码应该工作。

相关问题