如何检查用户是否是我网站上Facebook页面的粉丝? [英] How do I check if a user is a fan of my facebook page on my website?

查看:99
本文介绍了如何检查用户是否是我网站上Facebook页面的粉丝?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查我的用户是否是我的Facebook页面的粉丝.我认为应该这样做:

I want to check if my users are fans of my facebook page. I think something like this should do it:

    <script type="text/javascript" src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US"></script>
<script type="text/javascript">FB.init("my api key","xd_receiver.htm");</script>
    <script type="text/javascript">
    //<![CDATA[ 
    FB_RequireFeatures(["Api"], function(){

    var api = FB.Facebook.apiClient;
            api.pages_isFan(PAGE_ID,gigyaUser.FACEBOOK_USER_ID,function(response){
         alert(response);
    });

    });

    //]]>
    </script>

但是,由于某种原因,即使用户实际上是该页面的支持者,我仍会得到null.我想念什么吗?

However, for some reason I keep getting null even though the user is in fact a fan of the page. Am I missing something?

推荐答案

我认为您几乎是正确的. 此代码段对我非常有用.

I think you almost had that correct. This snippet works great for me.

假设: 1. fanPageUID =风扇页面的uid 2.用户UID是用户的UID 3.(并且您有一个活跃的会话)...这可能是困难的部分,但不是此问题的一部分.

assumes: 1. fanPageUID = the fan page's uid 2. and user UID is the UID of the user 3. (and you have an active session)... this may be the hard part, but not part of this question.

  function checkifFan() {
    FB_RequireFeatures(["Api"], function(){
    var api = FB.Facebook.apiClient.pages_isFan(fanPageUID,userUID,function(response){
        if (response==false) {
          setTimeout('checkifFan()', 300); //every 300ms check if they have pressed fan
        }
        else {
          location.reload();
        }
    });

    });
  }

这篇关于如何检查用户是否是我网站上Facebook页面的粉丝?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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