0

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.

jessica
  • 3,051
  • 2
  • 30
  • 31

1 Answers1

2

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.

Community
  • 1
  • 1
ifaour
  • 38,035
  • 12
  • 72
  • 79
  • Cool, but I was under the impression that running a URL through the URL Linter would clear FB's cache? Is that not the case? – jessica Feb 18 '11 at 15:57
  • Also -- am I still able to use FB.Event.subscribe if I remove the FB.init snippet? – jessica Feb 18 '11 at 16:04
  • 1
    @jessica: I don't think the URL Linter will clear the cache, if it's a dynamic website where pages have same structure (different content) then you need to wait for facebook to clear the cache – ifaour Feb 18 '11 at 16:47
  • 1
    @jessica: For your second question, it depends on what event you want to use if it's `LIKE` related then no, check this [answer](http://stackoverflow.com/questions/4978778/is-there-a-way-to-reload-the-page-after-fblike-is-clicked/4979190#4979190) for more details – ifaour Feb 18 '11 at 16:49
  • Thanks so much for your help. The cache thing is such a problem! I have to keep the button disabled while I wait for the cache to clear, otherwise the links and titles show up incorrectly in people's news feeds. Turning it on and off all day on the production site to check if it's cleared yet looks really bad. One last question -- I read here http://stackoverflow.com/questions/2876854/facebook-like-not-pulling-title/2877149#2877149 that once your page receives 10 likes the cache will never clear. Since my pages are incorrectly showing over 500 likes, is this going to be a problem? – jessica Feb 18 '11 at 18:11
  • Some of the pages are showing properly now! I do believe you're correct and it is completely a cache issue. On one of the pages that was showing correctly, I liked it, it showed up correctly in my news feed (and it also correctly showed just 1 like on the page). However when I clicked "undo" it went back to showing over 500 likes. Lame. I guess I will just leave it live and wait for the cache to work itself out. This is embarrassing to have on a production site. – jessica Feb 18 '11 at 18:31
  • 1
    @jessica: Actually it got updated check [Editing Meta Tags](http://developers.facebook.com/docs/opengraph/) it's 50 likes but you can still do something about it, faking the page by adding fake parameter for the affected pages..something like `?123` – ifaour Feb 18 '11 at 18:35
  • Thanks -- where would I add that parameter? in og:url or in the fb:like button code? – jessica Feb 18 '11 at 18:50
  • Thanks again. To clarify -- none of the pages have actually received over 500 likes -- I have no idea where that number came from. I do not mind if the like count resets to 0, the pages have only been up since yesterday. Like I said before, some of the pages have started showing up correctly (with the like count at 0 instead of at 500-something, and with correct titles and links in the news feed). Hopefully that behavior will propagate to the rest soon. – jessica Feb 18 '11 at 21:20
  • @jessica: Great then. BTW yes it seems that the URL Linter will clear the cache. – ifaour Feb 18 '11 at 21:23