You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

API v1.12中如何监听Facebook点赞按钮的点击事件?

关于Facebook API v1.12中监听点赞按钮点击事件的方法

Hey there! Based on the official Facebook developer post from November 2017, here's what you need to know about listening for like button clicks in API v1.12:

Yes, you absolutely can track when a user clicks the Facebook Like button in v1.12. The go-to method uses the Facebook JavaScript SDK's event subscription system.

Here's how to implement it:

  • First, make sure you've properly loaded and initialized the Facebook JavaScript SDK with your app ID.
  • Use the FB.Event.subscribe() method to listen for the edge.create event — this event fires every time a user clicks an official Facebook Like button.

Here's a quick code example to get you started:

// After initializing the SDK
FB.Event.subscribe('edge.create', function(targetUrl) {
  // Add your custom logic here — like logging the event, updating your UI, or sending data to your backend
  console.log('User liked this URL:', targetUrl);
});

A couple of important notes:

  • This only works with the official Facebook Like button component (the one rendered via the <div class="fb-like"></div> tag). Custom-built like buttons won't trigger this event.
  • While the 2017 post announced changes to some developer offerings, the edge.create event was still fully supported in v1.12. Later API versions did adjust some event permissions, but that doesn't affect v1.12 functionality.

内容的提问来源于stack exchange,提问作者Nikita Glusuchenko

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 04:22:00