检测单击Facebook赞按钮的时间 [英] Detect when Facebook like button is clicked

查看:106
本文介绍了检测单击Facebook赞按钮的时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下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/

edge.create和edge.remove JS SDK事件:这些事件将不再可访问.或者,您可以使用我们的Webhooks,并在有人喜欢您的Facebook页面之一时通知您.

edge.create and edge.remove JS SDK Events: These Events will no longer be accessible. As an alternative, you can use our Webhooks and be notified every time someone likes one of your Facebook Pages.

这篇关于检测单击Facebook赞按钮的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆