我为我的实验编写了一个简单的facebook按钮,以便我可以在我的应用程序中集成Facebook功能:
这是代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Facebook and twitter log in</title>
</head>
<body>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '843995905631867',
xfbml : true,
version : 'v2.2'
});
};
(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 = "sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<div
class="fb-like"
data-share="true"
data-width="450"
data-show-faces="true">
</div>
</body>
</html>
我收到了这些警告:
The "fb-root" div has not been created, auto-creating
fb:like failed to resize in 45s
我有一个空白的屏幕......我哪里错了?
答案 0 :(得分:0)
只需使用生成器即可获得正确的代码,它将起作用:https://developers.facebook.com/docs/plugins/like-button
你遗漏了一些东西,比如喜欢的网址(data-href)和fb-root div(这不重要,因为它会自动创建。