开发者

Changing Facebook API event subscribe only too run when a certain like button is clicked?

Using the Facebook API how can i change 开发者_StackOverflowthe event subscribe script to run only when a certian like button has been clicked? I will have many separate like buttons on my page and this code:

FB.Event.subscribe('edge.create', function(response) {
  // codey stuff
}); 

Will go off if any are clicked.. right? How do i change this?


You can't subscribe to only certain events, but if you check the response variable you get in the callback you'll get the URL of the object for which an edge was just created. From there, you can determine if it's the object you're interested in, and handle it accordingly.

FB.Event.subscribe('edge.create', function(response) 
{               
    if (response == "<whatever>") {
        // do stuff
    }
});

EDIT: Here's a jsFiddle example.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜