开发者

Unlike event similar to edge.create

开发者 https://www.devze.com 2023-01-21 08:05 出处:网络
Via the Facebook javascript API, you can subscribe to the \'event.create\' event to listen for when users \"Like\" something on a pag开发者_开发知识库e via the Like Plugin. Is it possible to respond t

Via the Facebook javascript API, you can subscribe to the 'event.create' event to listen for when users "Like" something on a pag开发者_开发知识库e via the Like Plugin. Is it possible to respond to the same user un-liking it as well? I don't see any events documented, wondering if this is a hidden feature.


You can now subscribe to the “edge.remove" event to know when a user unlikes a page. For example:

FB.Event.subscribe('edge.remove', function(href, widget) {
  alert('You just unliked '+href);
});

Announcement: http://developers.facebook.com/blog/post/446/ documented at http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe


Recently added:

http://bugs.developers.facebook.net/show_bug.cgi?id=10796


The javascript sdk does not have an event for this. I have run into this problem before. The only way to check if a user has unliked an item is to do a Graph or Rest query to determine if they currently like the item.


Unfortunately "edge.remove" won't get triggered when you dislike a facebook-page via "liked"-button (on the top right) and click on "unlike". -.-


This event is very useful to create a vote system. The js-script below does an ajax-call to a PHP-page that updates a database.

var _paq = _paq || [];
FB.Event.subscribe('edge.create', function(response) {
    var page = $("#pageid").val();
    $.post("ajax_vote.php", { page: page },
    function(data) {
        //alert("voted : " + data);
    });    
});

FB.Event.subscribe('edge.remove', function(response) {
    var page = $("#pageid").val();
    $.post("ajax_unvote.php", { page: page },
    function(data) {
        //alert("unvoted : " + data);
    });    
});
0

精彩评论

暂无评论...
验证码 换一张
取 消