问题描述
我有以下JavaScript代码
I have the following JavaScript code
<div class="fb-like-box" data-href="snip" data-colorscheme="light"
data-show-faces="false" data-header="false" data-stream="false"
data-show-border="true"></div>
我试图检测何时单击了赞"按钮.上面的代码呈现了一个iframe,因此我的jQuery事件处理程序为
I am trying to detect when the like button is clicked. The above code renders an iframe so my jquery event handler of
$('.fb-like-box > button').on('click', function() { console.log('Clicked'); });
从不开火.我试过将此div和其他内容包装到包装div中,并以$()调用为目标,但是仅在单击其他内容时才触发,而不是由Facebook SDK呈现的区域触发.
Never fires. I tried wrapping this div and other content in a wrapper div and target that in the $() call but it only fires when the other content is clicked, not the area that is rendered by the Facebook SDK.
推荐答案
https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/v2.3
您只需要订阅edge.create
事件即可获得赞.有关示例代码,请参见文档.
You just need to subscribe to the edge.create
event for likes. See docs for example code.
但是,正如所评论的那样,不允许您奖励喜欢的用户.阅读平台政策以获取更多信息: https://developers.facebook.com/policy/
But as commented, you are not allowed to reward users for liking. Read the platform policy for more information: https://developers.facebook.com/policy/
更新: https://开发人员. facebook.com/blog/post/2017/11/07/changes-developer-offerings/
这篇关于检测单击Facebook赞按钮的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!