facebook - Iframe Like 按钮未触发 edge.create

标签 facebook iframe facebook-like

我不想使用 xfbml。我需要像下面这样使用 iframe 按钮。但这并没有触发 edge.create

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
// initalize your Facebook App
  FB.init({
    appId  : '113869198637480',
    status : true, // check login status
    cookie : true, // enable cookies to allow the server to access the session
    xfbml  : true  // parse XFBML
  });
// subscribe to the event
FB.Event.subscribe('edge.create', function(response) {
  alert('you liked this');
});
FB.Event.subscribe('edge.remove', function(response) {
  alert('you unliked this');
});
</script>

<iframe id="test" src="http://www.facebook.com/plugins/like.php? 
       href=http://google.com/&amp;
       layout=button_count&amp;
       show_faces=false&amp;
       width=50&amp;
       action=like&amp;
       colorscheme=light&amp;
       height=21" 
       scrolling="no" frameborder="0" 
       style="border:none; overflow:hidden; width:50px;  
              height:21px;" 
       allowTransparency="true">

最佳答案

这完全是预料之中的; javascript 回调仅在使用社交插件的 Javascript 版本时可用,包括“赞”按钮。

Like Button documentation 中提到了这一点:

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

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

当您直接将“赞”按钮包含为 iFrame 时,无法将来自 Facebook 服务器的事件传播回您的 javascript 代码 - 在使用“赞”按钮的 XFBML 版本时,Facebook Javascript SDK 会处理此通信

关于facebook - Iframe Like 按钮未触发 edge.create,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12910800/

相关文章:

iframe - vimeo 域隐私和 &lt;iframe&gt; 的安全性

iphone - 使用 Facebook iOS SDK 登录 UIWebView

html - 如何结合来 self 的网站和 Facebook 本身的 Facebook 点赞

facebook - 从FB自己的CDN加载FB logo

java - Facebook android SDK 图形请求 - 访问 token 问题

html - iframe 的滚动条问题

css - 以响应方式将 Bootstrap 网页嵌入到 iframe 中

wordpress - 点赞按钮问题

android - Libgdx 中的 Facebook 集成

facebook - 如何获取链接到 Facebook Open Graph 中对象的操作(只知道对象 URL)?