Thursday, 23 March 2017

How to Add a Facebook Comments Box or Like Button to Your Website

Go to developers.facebook.com and log in.

Search for Social plugin. Go to like button.


There is a form on this page to be fill to set up the like button.


Enter the URL to be like by the people.

Choose the action type as like.

Click on the get code link.


The code looks like this.

Include the JavaScript SDK on your page once, ideally right after the opening <body> tag.

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


Place this code wherever you want the plugin to appear on your page.
<div class="fb-like" data-href="http://localhost/index1.php" data-layout="standard" data-action="like" data-size="small" data-show-faces="true" data-share="true"></div>

The final result will look like this



No comments:

Post a Comment