【问题标题】:facebook send button ignores OG meta tagsfacebook 发送按钮忽略 OG 元标签
【发布时间】:2013-04-19 07:08:28
【问题描述】:

我正在使用 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 标签,并且调试器没有报告 theHomePage.php 的任何问题。

所以问题来了:当我点击“发送”按钮并出现发送对话框时:

  • 我的“logo.png”图像丢失(尽管 logo.png 图像确实出现在调试器中)

  • “消息”字段为空 - 不应该用我的 og:description 冗长文本填充吗?

  • 发送对话框底部出现错误的页面标题

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

我还需要在这里做些什么,以便我的元标记显示在“发送”对话框中,当 发送按钮被点击了吗?

【问题讨论】:

  • 也许您可以分享相关页面的地址,这可能会有所帮助。另外,请在您的页面中添加发送按钮的代码。
  • 好的,我在上面的问题中添加了你提到的其他代码——这是我第一次使用任何 Facebook 插件,所以我确定我把它搞砸了,但我看不到where -- 标签在正确的位置,Facebook 调试器成功找到并解析它们。

标签: facebook


【解决方案1】:

根据您在问题中提供的信息,我假设您调试的 url 是 www.thesite.com/theHomePage.php 并且您会根据 og 标签获得预期的数据。

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

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

【讨论】:

  • 好吧,解决了它。为了使它工作,我必须更改按钮中的 data-href 以匹配 og:url 元标记。现在“发送”对话框出现了,其中显示了我的所有元标记(图像、网址、描述、标题)。谢谢!
  • 组合的点赞和发送按钮在 atm 处被窃听:developers.facebook.com/bugs/…
  • @wantTheBest 但是为什么data-hrefog:url 需要相同?当它们不同时,我会收到 401 Unauthorized。但是在任何浏览器中都可以毫无问题地访问不同的 URL。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-03-15
  • 1970-01-01
  • 2022-01-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多