如何设置Facebook的开放图形标签,如按钮?

时间:2011-11-28 10:23:10

标签: facebook facebook-like opengraph

我的页面中有以下元素:

<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:og="http://ogp.me/ns#"
  xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
...

<meta property="og:title" content="testitle"/>
<meta property="og:url" content="http://www.hoteljo.de"/>
<meta property="og:image" content="http://www.hoteljo.de/images/button-60.png"/>
<meta property="og:type" content="website"/>
<meta property="og:site_name" content="site name"/>
<meta property="fb:app_id" content="id"/>
<meta property="fb:admins" content="1160534546"/>
<meta property="og:description" content="description"/>
</head>
<body>
<div id="fb-root"></div>
<script type="text/javascript">
  window.fbAsyncInit = function() {
    FB.init({appId: 'id',
             status: true,
             cookie: true,
             xfbml: true});
  };
  (function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol +
      '//connect.facebook.net/de_DE/all.js';
    document.getElementById('fb-root').appendChild(e);
  }());
</script>

   <fb:like href='http://www.hoteljo.de' send='false' layout='button_count'    
 show_faces='false' font='verdana'></fb:like>

我在头部插入了开放图形描述,并在body元素中包含了Facebook like按钮。 但仍然在https://developers.facebook.com/tools/debug我得到错误。我需要改变什么?

2 个答案:

答案 0 :(得分:0)

您有循环重定向路径错误:

请参阅https://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fwww.site.de

您的原始网址(http://www.site.de/)链接到另一个网址(https://www.office-site.de/),该网址链接回原始网址(http:// www。 site.de/)通过您的依赖项中的rel =“canonical”链接等。

确定您的规范网址,并坚持下去。

答案 1 :(得分:0)

此处的问题是页面http://www.hoteljo.de通过302 HTTP代码重定向到http://www.hoteljo.de/signup。所以Facebook无法从主页http://www.hoteljo.de解析OpenGraphs!

您应该尝试删除该重定向或使用javascript进行设置(因为这是临时重定向)。