facebook发送按钮忽略OG元标记

时间:2012-04-18 22:10:26

标签: facebook

我正在使用Facebook发送按钮,我将以下内容放在显示发送按钮的页面上:

编辑:我在此处的代码中添加了页面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:url" content="http://www.thesite.com/theHomePage.php"/>
  <meta property="og:title" content="Thesite is now live with a Send button!"/>
  <meta property="og:image" content="http://www.thesite.com/images/logo.png"/>
  <meta property="og:description" content="This is test description verbiage"/>

编辑:我在发送按钮代码下方添加了

  <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";
            fjs.parentNode.insertBefore(js, fjs); 
        }
        (document, 'script', 'facebook-jssdk'));
       </script>

           <div class="fb-send" data-href="http://www.thesite.com"></div>

当我在http://developers.facebook.com/tools/debug/使用Facebook调试器时,它会告诉我:

    Raw Open Graph Document Information


   Meta Tag: <meta property="og:url" content="http://www.thesite.com/theHomePage.php" />
   Meta Tag: <meta property="og:title" content="Thesite is now live with a Send button!" />
   Meta Tag: <meta property="og:image" content="http://www.thesite.com/images/logo.png" />
   Meta Tag: <meta property="og:description" content="his is test description verbiage" />

Facebook调试器清楚地看到我的Meta标签和调试器没有报告HomePage.php的任何问题。

所以这就是问题所在:当我点击“发送”按钮并出现发送对话框时:

  • 我的'logo.png'图片丢失了(尽管logo.png图片会出现在调试器中)

  • “消息”字段为空 - 不应该填充我的 og:description 措辞文字吗?

  • 错误的页面标题显示在“发送”对话框的底部

  • 并且显示的网址不是http://www.thesite.com/theHomePage.php - 而是显示的网址是 http://www.thesite.com/

我还需要做些什么才能让我的元标记出现在'Send'dialog框中 单击发送按钮?

1 个答案:

答案 0 :(得分:4)

根据您在问题中提供的信息,我假设您调试的网址是 www.thesite.com/theHomePage.php ,为此您可以获得基于og标记的预期数据。

但是从发送按钮的代码中,您提供了 www.thesite.com / 的网址,这是一个不同的网址。 尝试调试该网址,看看你得到了什么。

Facebook根据网址对数据进行索引,因此网址中的任何小差异都会导致图表中出现不同的对象。 因此,您需要将确切的网址放在 data-href 属性中。