出现问题页面标题、点赞数和页面 url

发布于 2024-10-18 03:24:56 字数 2233 浏览 1 评论 0原文

我的网站中有一组页面使用 FBML 方法插入 FB 推荐按钮。我的问题是,我网站上的每个页面都显示完全相同的推荐计数(“557 人推荐此页面”,即使我刚刚安装了该按钮),当我尝试自己推荐它时,它会显示在我的新闻源中错误的页面标题、错误的 URL,当然,网站上的每个推荐按钮都会递增。这是我的代码:

og 标签(我用匿名值替换了这些标签,以保护我的客户不会看起来像他们有一个白痴开发人员);):

    <meta property="og:title" content="XXX page title"/>
    <meta property="og:type" content="movie"/>
    <meta property="og:url" content="http://abc.xyz.com/path/to/my/page/"/>
    <meta property="og:site_name" content="XXX site name"/>
    <meta property="fb:admins" content="xxx my facebook id"/>
    <meta property="og:description" content="xxx short description"/>

...然后就在正文中:

<body>
<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId  : 'xxxxx',
      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';
    e.async = true;
    document.getElementById('fb-root').appendChild(e);
  }());
</script>

...然后在页面中(我使用 FBML 方法的唯一原因是这样我可以跟踪谷歌分析中的推荐事件——这应该是无关的,但为了充分披露,我也在这里包含了该代码)...

<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
        <script type="text/javascript">
            FB.Event.subscribe('edge.create', function(href, widget) {
                _gaq.push(['_trackEvent', '<?php echo $item->type ?>', 'Facebook Recommend', '<?php echo $item->title ?>']);
            });
        </script>
<!-- FB LIKE BUTTON INSERTED HERE -->
        <fb:like href="<?php echo urlencode('http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] )?>" show_faces="false" width="450" action="recommend" font="arial" colorscheme="dark"></fb:like>

链接显示在我的提要中的是 http://abc.xyz.com/path/to/my /(URL的最后一段丢失),并且标题是旧的;当我设置这个时,我意识到所有页面都有相同的标题,所以从那以后我给了它们不同的标题。我已经通过 URL linter 运行了几个 URL,没有错误,并且所有数据看起来都是正确的。

I have a set of pages in my site that are using the FBML method of inserting a FB Recommend button. My problem is that every page on my site shows the exact same recommend count ("557 people recommend this page" even though I just installed the button), and when I've tried to Recommend it myself, it shows up in my news feed with the wrong page title, the wrong URL, and of course, every recommend button on the site is incremented. Here is my code:

og tags (I replaced these with anonymous values to protect my client from looking like they have an idiot developer) ;) :

    <meta property="og:title" content="XXX page title"/>
    <meta property="og:type" content="movie"/>
    <meta property="og:url" content="http://abc.xyz.com/path/to/my/page/"/>
    <meta property="og:site_name" content="XXX site name"/>
    <meta property="fb:admins" content="xxx my facebook id"/>
    <meta property="og:description" content="xxx short description"/>

...then just inside the body:

<body>
<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId  : 'xxxxx',
      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';
    e.async = true;
    document.getElementById('fb-root').appendChild(e);
  }());
</script>

...and then later on in the page (the only reason I'm using the FBML method is so I can track the recommend events in google analytics -- this should be unrelated, but for the purposes of full disclosure, I'm including that code here too)...

<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
        <script type="text/javascript">
            FB.Event.subscribe('edge.create', function(href, widget) {
                _gaq.push(['_trackEvent', '<?php echo $item->type ?>', 'Facebook Recommend', '<?php echo $item->title ?>']);
            });
        </script>
<!-- FB LIKE BUTTON INSERTED HERE -->
        <fb:like href="<?php echo urlencode('http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] )?>" show_faces="false" width="450" action="recommend" font="arial" colorscheme="dark"></fb:like>

The link that shows up in my feed is http://abc.xyz.com/path/to/my/ (the last segment of the URL is missing), and the title is an old one; I realized that all the pages had the same title when I was setting this up, and so I gave them different titles since. I have run several of my URLs through the URL linter and there are no errors, and all the data looks correct.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

波浪屿的海角声 2024-10-25 03:24:56

这里有两个注意事项:

  1. 由于您使用 URL Linter 检查了多个 URL,并且结果按预期出现,这意味着这是一个缓存问题,请阅读 这个
  2. 如果您不使用 Facebook Graph API...或除 Like 插件之外的任何 Facebook 相关服务,则不需要第一个 Facebook Javascript 初始化片段,但如果使用它,则 ()。

编辑:
根据评论,某些页面的赞数超过 50,这意味着您无法再更改 title

您可以更新您的属性
页面通过更新您的页面
标签。请注意 og:title 和 og:type
只能在最初-之后编辑
您的页面标题获得 50 个赞
变得固定,并且在您的页面之后
收到 10,000 个赞,类型变为
固定的。这些属性被固定为
避免让喜欢的用户感到惊讶
页面已经。更改标题
或在这些限制之后键入标签
达到什么也不做,你的页面
保留原始标题和类型。

来源[编辑元标记]

但是如果您确实需要更改标题并且您可以可能失去点赞数,那么您可以添加一个假参数URL 元标记的末尾,以便 Facebook 认为这是一个新页面:

http://www.domain.com/page.php?123

请注意,我从未在新的 Like 插件中使用过此技术。

Here are two notes:

  1. Since you checked several URLS using the URL Linter and the result came up as expected this means it's a caching problem, read this.
  2. If you are not using Facebook Graph API...or any Facebook related services other than the Like Plugin, then the first Facebook Javascript initialization snippet is not needed but if it's used then (<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>) is not needed.

EDIT:
Based on the comments, some of the pages have more than 50 likes this means you can't change the title anymore:

You can update the attributes of your
page by updating your page's
tags. Note that og:title and og:type
are only editable initially - after
your page receives 50 likes the title
becomes fixed, and after your page
receives 10,000 likes the type becomes
fixed. These properties are fixed to
avoid surprising users who have liked
the page already. Changing the title
or type tags after these limits are
reached does nothing, your page
retains the original title and type.

source [Editing Meta Tags].

BUT if you really need to change the title and you are okay of probably losing the likes' count, then you can add a fake parameter to the end of the URL meta tag so that Facebook thinks it's a new page:

http://www.domain.com/page.php?123

Please note that I've never used this technique with the new Like Plugin.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文