在Facebook连接中,我如何检查用户是否是我的Facebook页面的粉丝?有可能跟踪吗? [英] In facebook connect, how can I check if a user is a fan of my facebook page? Is it possible to track?

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

问题描述

我正在尝试确定用户是否是Facebook粉丝。我加载了facebook JS库并初始化:

 < script type =text / javascriptsrc =http:// static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US\"></script> 

FB_RequireFeatures([XFBML,Connect,Api],function(){FB.init(my_api_key,xd_receiver.htm)});

FB.ensureInit(function(){
FB.ApiClient.pages_isFan(my_profile_id,some_UID,callback);
});

但是当我用FB.ApiClient.pages_isFan调用API客户端时,我收到一个JS错误 -

  FB.ApiClient未定义

我也使用FBML粉丝标签显示成为粉丝按钮:

  ; fb:fan profile_id =my_profile_idstream =0connections =10logobar =1width =300>< / fb:fan> 

当点击成为粉丝按钮或用户有成功成为粉丝。



业务逻辑非常简单 - 如果他们成为粉丝,请在我的数据库中跟踪。然后,如果他们再次尝试成为粉丝,请查看图书馆是否是粉丝,如果他们是粉丝,说你已经是粉丝,如果没有,请显示该小部件。使用新的 JS SDK

 < fb:login-button perms =user_likes > 
授予允许访问权限的权限
< / fb:login-button>

< button onclick =checkDoesLike()>检查用户是否喜欢页面< / button>

< h1>像这个应用程序的页面< / h1>
< fb:like-box profile-id =184484190795>< / fb:like-box>

< script>
window.checkDoesLike = function(){
FB.api({method:'pages.isFan',page_id:'184484190795'},function(resp){
if(resp){
Log.info('你喜欢应用程序');
} else {
Log.error(你不喜欢应用程序);
}
});
};
< / script>

一个工作示例: http://fbrell.com/fb.api/does-like


I am trying to determine if a user is a facebook fan. I load the facebook JS library and initialize:

<script type="text/javascript" src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US"></script>

FB_RequireFeatures(["XFBML","Connect","Api"], function() { FB.init("my_api_key","xd_receiver.htm") });

FB.ensureInit(function () {     
        FB.ApiClient.pages_isFan(my_profile_id,"some_UID",callback);
    });

However when I call the API client with FB.ApiClient.pages_isFan, I get a JS error -

FB.ApiClient is undefined

I am also using the FBML fan tag to display the "become a fan" button:

<fb:fan profile_id="my_profile_id" stream="0" connections="10" logobar="1" width="300"></fb:fan>

And would like to be notified when either the "become a fan" button is clicked or a user has successfully become a fan.

The business logic is pretty simple - If they become a fan, track it in my database. Then if they try to become a fan again, check with the library if they are a fan and say "You are already a fan" if they are a fan, show the widget if not.

解决方案

Using the new JS SDK:

<fb:login-button perms="user_likes">
  Grant Permissions to Allow access to Likes
</fb:login-button>

<button onclick="checkDoesLike()">Check if user Likes the Page</button>

<h1>Like this Application's Page</h1>
<fb:like-box profile-id="184484190795"></fb:like-box>

<script>
window.checkDoesLike = function() {
  FB.api({ method: 'pages.isFan', page_id: '184484190795' }, function(resp) {
    if (resp) {
      Log.info('You like the Application.');
    } else {
      Log.error("You don't like the Application.");
    }
  });
};
</script>

A working example: http://fbrell.com/fb.api/does-like

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

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