2010-11-13 77 views
3

我试图添加一个Facebook的按钮到一个网站im工作,但没有我添加的元属性显示出来。Facebook喜欢元问题

我在我的HTML以下(不包括不相关部分)

<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml" 
     xmlns:og="http://opengraphprotocol.org/schema/" 
     xmlns:fb="http://www.facebook.com/2008/fbml"> 

<head> 
... 
<meta property="og:site_name" content="My Site" /> 
<meta property="og:title" content="Some Product"/> 
... 
</head> 

<body> 
<div id="fb-root"></div> 
<script> 
    window.fbAsyncInit = function() { 
    FB.init({ 
     appId : 'MYAPIKEY', 
     status : true, // check login status 
     cookie : true, // enable cookies to allow the server to access the session 
     xfbml : true // parse XFBML 
    }); 
    }; 

    (function() { 
    var e = document.createElement('script'); 
    e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js#xfbml=1'; 
    e.async = true; 
    document.getElementById('fb-root').appendChild(e); 
    }()); 
</script> 
... 
... 
<fb:like layout="button_count"></fb:like> 
... 

在什么即时做错了会非常赞赏任何指针。

+0

究竟发生了什么?你在页面上看到的结果是什么? – 2010-11-13 18:30:37

回答

2

我意识到,问题是,我在我的本地计算机上测试机器。它开始工作,一旦我把网站在线。

0

相信Facebook页面

http://developers.facebook.com/docs/guides/web

它应该是这样的:

<iframe src="http://www.facebook.com/widgets/like.php?href=http://example.com" 
     scrolling="no" frameborder="0" 
     style="border:none; width:450px; height:80px"></iframe> 
+0

这就是如果您使用iframe。 – zsquare 2010-11-13 17:20:24

0

您遗漏了一些必要的开放图形标签。他们被定义为here。至少你正在寻找 -

<meta property="og:title" content="Title of page"/> 
<meta property="og:type" content="CONTENT TYPE"/> 
<meta property="og:url" content="URL of PAGE"/> 
<meta property="og:image" content="URL of IMAGE"/> 
<meta property="og:site_name" content="SITE NAME"/> 
<meta property="fb:admins" content="USER_ID"/>