Facebook的按钮没有出现在我的页面上,我做错了什么?
问题描述:
我正在建设一个网站,我希望能够“喜欢”它使用Facebook。我看了一眼自己的SDK,它似乎相当直截了当......Facebook的按钮没有出现在我的页面上,我做错了什么?
我“制造”这样的:
<html>
<head>
</head>
<body>
<h1>Testing the Facebook like button</h1>
<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_GB/all.js#xfbml=1&appId=177127339057410";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-like" data-href="http://yannbane.blogspot.com/" data-send="false" data-width="450" data-show-faces="true"></div>
</body>
</html>
我保存为“index.html的”我的电脑上。现在,当我尝试打开它时,它只显示“测试Facebook像按钮”标题,并继续加载,并没有真正发生。怎么来的?我当然不会试图“喜欢”index.html,但我的博客(http://yannbane.blogspot.com/),所以我认为应该没有问题,在本地打开它...
答
在你的头,你需要有opengraph信息,Facebook要求它出现类似的按钮。
meta标签应该是这样的
元属性= “OG:标签名” CONTENT = “变量值”
所需的信息是
-og:标题
-og:键入
-og:图像
-og:URL
-og:SITE_NAME
-fb:管理员
你可以在这里阅读更多https://developers.facebook.com/docs/reference/plugins/like/
我没有使用过这个API,但应该js.src =“//connect.facebook.net在协议开始之前”//“? (像http://)? – Tim 2012-02-09 14:25:59