开发者

Facebook like meta problems

开发者 https://www.devze.com 2023-01-25 11:54 出处:网络
Im trying to add a facebook like button to a website im working on, but none of the meta attributes i add show up.

Im trying to add a facebook like button to a website im working on, but none of the meta attributes i add show up.

I have the following in my html, (irrelevant parts not included)

<!DOCTYPE html>
<html xml开发者_StackOverflow中文版ns="http://www.w3.org/1999/xhtml"
      xmlns:og="http://opengraphprotocol.org/schema/"
      xmlns:fb="http://www.facebook.com/2008/fbml">

<head>
...
<meta property="og:site_name" content="My Site" /> 
<meta property="og:title" content="Some Product"/> 
...
</head>

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

Any pointers on what im doing wrong would be much appreciated.


I realised, the problem was that i was testing the machine on my local computer. It started working once i put the website online.


Believing the Facebook page

http://developers.facebook.com/docs/guides/web

it should look like this :

<iframe src="http://www.facebook.com/widgets/like.php?href=http://example.com"
        scrolling="no" frameborder="0"
        style="border:none; width:450px; height:80px"></iframe>


You're missing a number of the required open graph tags. They're defined here. At a minimum you're looking for -

<meta property="og:title" content="Title of page"/>
<meta property="og:type" content="CONTENT TYPE"/>
<meta property="og:url" content="URL of PAGE"/>
<meta property="og:image" content="URL of IMAGE"/>
<meta property="og:site_name" content="SITE NAME"/>
<meta property="fb:admins" content="USER_ID"/>
0

精彩评论

暂无评论...
验证码 换一张
取 消