Search code examples
facebookfacebook-likexfbml

FB like button for other pages


I want to add a facebook like button to my facebook page tab, not for my own page but for the page the user is coming from.
Now if I use the id of the page for my like button

<div class="fb-like" id="like-button" href="http://www.facebook.com/PAGE_ID
data-send="false" data-width="450" data-show-faces="false"></div>

<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=MY_ID";
      fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>`  

The page doesn't get the like.

Is this just not possible or am I doing it wrong?


Solution

  • The Like button is not intended to be used in this way. The like button is only for webpages not hosted on facebook.com.

    But what you're trying to do actually can work, albeit buggily. The problem is that your page URL is not correct:

    http://www.facebook.com/PAGE_ID

    When you open this URL in a web-browser, it will redirect you to the correct page URL.

    If you use the correct page URL for your like button, your page will receive the like, however the like button will probably report an error.