Facebook的LIKE按钮不会在网页中启动edge.create或edge.remove [英] LIke button of facebook will not fire edge.create or edge.remove in web page

查看:464
本文介绍了Facebook的LIKE按钮不会在网页中启动edge.create或edge.remove的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经倾向于给出stackoverflow问题的答案

I have prefered given answer of stackoverflow question

像按钮不会触发edge.create或edge.remove

但是我正在在crome浏览器中的开发者工具控制台中看到以下错误

But I am getting following error when see in developer tool console in crome browser


未捕获参考错误:FB未定义fb.php:20


应用程序配置不允许发送URL:应用程序设置不允许一个或多个给定的URL,它必须与网站URL或Canvas URL匹配,否则域必须是一个应用程序的域名。

"Uncaught ReferenceError: FB is not defined fb.php:20

Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains."

代码如下

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<html xmlns:fb="http://ogp.me/ns/fb#">
 <body>
 <div id="fb-root"></div>
 <script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=xxxxx";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

FB.Event.subscribe('edge.create',
    function(response) {
        alert('You liked the URL: ' + response);
    }
);

FB.Event.subscribe('edge.remove',
    function(response) {
        alert('You UNliked the URL: ' + response);
    }
);

</script>
<div class="fb-like" data-href="https://developers.facebook.com/docs/plugins/" data-layout="standard" data-action="like" data-show-faces="true" data-share="true"></div>

 </body>
</html>

如何解决,请帮助我。

谢谢你。

推荐答案

您尚未初始化 FB.init() ,没有它,你不能进行API调用 - p>

You have not initialized the FB.init(), without which you can not make API calls-

window.fbAsyncInit = function() {
    FB.init({
      appId      : '510509449056378',
      status     : true,
      xfbml      : true
    });
    FB.Event.subscribe('edge.create',
       function(response) {
         alert('You liked the URL: ' + response);
       }
    );

    FB.Event.subscribe('edge.remove',
      function(response) {
         alert('You UNliked the URL: ' + response);
      }
    );
};

(function(d, s, id) {
   var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=510509449056378";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

这篇关于Facebook的LIKE按钮不会在网页中启动edge.create或edge.remove的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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