Event handling to detect if user clicks a 'Like' button in XFBML page

ε祈祈猫儿з 提交于 2019-12-20 10:37:31

问题


I have a Facebook connect app / canvas IFrame app which has a Like control for a fanpage.

I'd like to detect when the user clicks the Like button to be able to display additional info (a discount coupon code).

I'm using the latest Javascript API but the events that can be handled doesn't seem to include detection of social widget controls. The documentation for the Like Plugin doesn't show any events.

However I know its definitely possible because if I have two Like buttons on a page they both instantly update each other if I like or unlike whatever it is.


Edit: It is specifically allowed to require someone to become a fan for a promotion :

4.2 In the rules of the promotion, or otherwise, you will not condition entry to the promotion upon taking any action on Facebook, for example, updating a status, posting on a profile or Page, or uploading a photo.

You may, however, condition entry to the promotion upon becoming a fan of a Page.


回答1:


I think Facebook updated their documentation since I first looked :

Now its clearer :

http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe

A 'like' click is the edge.create event




回答2:


Official FAQ:

Q: How do I know when a user clicks a Like button?

A: If you are using the XFBML version of the button, you can subscribe to the 'edge.create' event through FB.Event.subscribe.

Source: Core Concepts › Social Plugins › Like Button



来源:https://stackoverflow.com/questions/2837999/event-handling-to-detect-if-user-clicks-a-like-button-in-xfbml-page

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!