Facebook I like button not working all the time
Asked Answered
G

4

12

I have used the following code to implement the like - button:

Header

<!-- Facebook Metatags -->
<meta property="og:image" content="http://mysite/logo.gif"/>
<meta property="og:locality" content="mycity"/>
<meta property="og:country-name" content="Germany"/>
<meta property="og:latitude" content="52.xxxxxxx"/>
<meta property="og:longitude" content="9.xxxxxxx"/>
<meta property="og:type" content="product"/>
<meta property="og:site_name" content="mypage.com"/>
<meta property="og:url" content="http://mypage.de/myproduct/myproductkey"/>
<meta property="og:title" content="Myproduct Description"/>

Body on mypage.de/myproduct/myproductkey

<div id="facebook-likebox">
<script src="http://connect.facebook.net/de_DE/all.js#xfbml=1"></script>
<fb:like href="http://mypage.de/myproduct/myproductkey" width="450" height="90" show_faces="false"></fb:like>
</div>

The result is inconsistent: Most of the time it works, but sometimes I get this error:

You failed to provide a valid list of administators. You need to supply the administors using either a \"fb:app_id\" meta tag, or using a \"fb:admins\" meta tag to specify a comma-delimited list of Facebook users.

This error makes no sense because when I call the page later or somebody else calls the page it works again. Any idea what is wrong here.

EDIT

I updated the site with these meta tags

<meta property="fb:admins" content="xxx"/>
<meta property="fb:app_id" content="xxx"/>

I rechecked the ids on https://graph.facebook.com/xxx

But I still get get errors sometimes. The new error is:

The app ID "xxx" specified within the "fb:app_id" meta tag was invalid.

But most of the time everyrthing works. Does anybody have any idea on how to solve this issue?

EDIT 1

Our site uses a load balancer and has a lot of external scripts (E-Tracker and other tracking solutions)

EDIT 2

We used LINT https://developers.facebook.com/tools/lint/ to check the page

It gives sometime an error (invalid app_id )and sometimes returns as valid. But the app-id from the meta-tags is allways parsed correctly and it is the valid app-id.

Guck answered 11/2, 2011 at 15:6 Comment(1)
Facebook changed their buttons recently. It seems to me Share works better than Like now. Your og:type has more influence on how things look when shared and of course bigger is better when it comes to images now in social media.Wen
G
3

It turns out that the reason for the inconsistent behaviour was the loadbalancer. We deactivated loadbalancing and LINT always showed consistent results.

I have no idea what the Load balancing changed. The meta-tags are similar.

I used the admins- metatag. I did not have to use the app-id tag. Thats how it is written in the specification.

Guck answered 14/2, 2011 at 17:7 Comment(1)
Did you find solution that didn't require you to turn off LoadBalancing? I'm running into similar problem and obviously can't turn off LoadBalancing just because of Facebook.Microcline
A
4

The Facebook Like Plugin requires six attributes when using the open graph meta tags:

  • og:title - The title of the entity.
  • og:type - The type of entity. You must select a type from the list of Open Graph types.
  • og:image - The URL to an image that represents the entity. Images must be at least 50 pixels by 50 pixels. Square images work best, but you are allowed to use images up to three times as wide as they are tall.
  • og:url - The canonical, permanent URL of the page representing the entity. When you use Open Graph tags, the Like button posts a link to the og:url instead of the URL in the Like button code.
  • og:site_name - A human-readable name for your site, e.g., "IMDb".
  • fb:admins or fb:app_id - A comma-separated list of either the Facebook IDs of page administrators or a Facebook Platform application ID. At a minimum, include only your own Facebook ID.

So just add your facebook ID:

<meta property="fb:admins" content="your_FB_ID"/>
Actinic answered 11/2, 2011 at 16:55 Comment(3)
I had a similar problem, adding all these tags solved it. I think it's the fb:app_id that did the trick.Warder
No such thing as an og:admins tag. It's fb:adminsLorenzo
@Jason, of course it's fb:admins! thanks for spotting this typo!Actinic
P
4

I spent a good couple of hours on this blasted Like button, but it is finally working for me! I had added the admin_id and app_id properties and it still flagged the same error.

Here is a check list to make sure you have what you need.

1) Your Doc type is probably wrong. I can't remember where I got this information, but use this instead:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">

2) You need to import the XML namespaces. Change your HTML tag to something like this:

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

I used the HTML5 script on my website. So here's a copy-pasta for your reference.

<?php $current_url = "http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]; ?>
<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_GB/all.js#xfbml=1&appId=YOUR_APP_ID";
        fjs.parentNode.insertBefore(js, fjs);
      }(document, 'script', 'facebook-jssdk'));
</script>
<div class="fb-like" data-href="<?php echo $current_url; ?>" data-send="false" data-layout="button_count" data-width="80" data-show-faces="false"></div>

Also, it takes a couple of minutes to propagate. I waited 15 minutes and suddenly... it worked.

Posterity answered 1/11, 2011 at 16:33 Comment(0)
G
3

It turns out that the reason for the inconsistent behaviour was the loadbalancer. We deactivated loadbalancing and LINT always showed consistent results.

I have no idea what the Load balancing changed. The meta-tags are similar.

I used the admins- metatag. I did not have to use the app-id tag. Thats how it is written in the specification.

Guck answered 14/2, 2011 at 17:7 Comment(1)
Did you find solution that didn't require you to turn off LoadBalancing? I'm running into similar problem and obviously can't turn off LoadBalancing just because of Facebook.Microcline
L
-2

I found the solution!

the problem is in the URL address, it has to be:

<meta property="og:url" content="http://www.yoursite.com/index.php" />

I used this and it works

Lendlease answered 21/10, 2011 at 21:10 Comment(1)
This question was already accurately answered (with a different, more thorough, and more correct answer) eight months ago...Yablon

© 2022 - 2024 — McMap. All rights reserved.