简体   繁体   English

Facebook Like Box-监控点击

[英]Facebook Like Box - monitoring clicks

Is it possible to somehow monitor who "Likes" my Facebook page, by intercepting the clicks in the Facebook Like Box? 是否可以通过拦截Facebook Like Box中的点击来以某种方式监视谁“喜欢”我的Facebook页面?

http://developers.facebook.com/docs/reference/plugins/like-box http://developers.facebook.com/docs/reference/plugins/like-box

I would like to find out if the user who comes to my site already likes it, and enable some additional functionality based on this (for example, less advertising). 我想了解访问我网站的用户是否已经喜欢它,并在此基础上启用一些附加功能(例如,减少广告投放)。

You can use the javascript sdk to subscribe to the event edge.create. 您可以使用javascript sdk订阅事件edge.create。 See the documentation here for that: http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe 请参见此处的文档: http : //developers.facebook.com/docs/reference/javascript/FB.Event.subscribe

FB.Event.subscribe('edge.create', function(response) {
  // A user liked the item, read the response and handle
});

Note, this will only work if you are using the xfbml version of the Like box. 请注意,这仅在使用“喜欢”框的xfbml版本时有效。 It wont work on the iframe version. 它不适用于iframe版本。

I don't know how to fetch just all people that have pressed the like button for an object, but you can subscribe to the like-button-press event. 我不知道如何仅获取按下对象的“喜欢”按钮的所有人,但是您可以订阅“喜欢按钮”事件。 You can then use the information about the current user, and save it to your own database. 然后,您可以使用有关当前用户的信息,并将其保存到自己的数据库中。 The event that you are listening to is edge.create , and you do that with FB's own FB.Event.subscribe . 您正在监听的事件是edge.create ,您可以使用FB自己的FB.Event.subscribe进行操作 It could look something like this: 它可能看起来像这样:

window.fbAsyncInit = function() {
    FB.init({
      appId  : 'xxxxxxxxxxxxxxxxxxxxxxxxx',
      status : true, // check login status
      cookie : true, // enable cookies to allow the server to access the session
      xfbml  : true  // parse XFBML
    });
    FB.Event.subscribe('edge.create', function(href, widget) {
        FB.api('/me', function(response) {
            alert(response.first_name + " " + response.last_name + ":" + response.id +" pressed " + href); // Replace this with an ajax call to your server
        });
    });
};

It's embedded in an iFrame, so from the way they suggest you implement it, no it isn't possible. 它嵌入在iFrame中,因此从他们建议您实现它的方式来看,这是不可能的。

However if you take a look at the code: 但是,如果您看一下代码:

http://www.facebook.com/plugins/likebox.php?href=http://www.facebook.com/platform&width=292&colorscheme=light&connections=10&stream=true&header=true&height=587 http://www.facebook.com/plugins/likebox.php?href=http://www.facebook.com/platform&width=292&colorscheme=light&connections=10&stream=true&header=true&height=587

There may be a way if you fiddle with it to call another function on the like buttons click that calls an ajax function you determine if you host all the code on your site, although FB probably has put things in place to not make that possible, or if it is it may be against T&C so worth checking out. 如果FB摆弄着它来调用另一个函数(例如单击ajax函数),则可能有一种方法可以确定您是否在站点上托管了所有代码,尽管FB可能已将其放置在适当的位置,以致于无法实现,或是否有可能违反T&C,所以值得一试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM