Friday 24 June 2016

How to integrate facebook like button in website?

How to integrate facebook like button  in website

Question: What is facebook like button?
Facebook give an embed code for like button, when you embed code this code people can like your page with this. They can also view friends who already have like your page.

Question: What are the requirement for facebook like button?
You must have following:
  1. Facebook Account
  2. Facebook App, If not https://www.facebook.com/help/172925542764476
  3. An Website where you will you will embed the code.



Question: How to get embed code for like button?
Open https://developers.facebook.com/docs/plugins/like-button and follow below steps
  1. Choose an URL of a website Page you want to use with the like button.
  2. Code Configurator from https://developers.facebook.com/docs/plugins/like-button#configurator
  3. Click on "Get Code" and past the code in website



Question: Give the sample code of Facebook like button?
<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_US/sdk.js#xfbml=1&version=v2.6&appId=508427595967225";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div class="fb-like" data-action="like" data-href="http://www.web-technology-experts-notes.in" data-layout="standard" data-share="true" data-show-faces="true">
</div>
Output