Friday, April 19, 2013

Facebook application creation and Facebook like with counts

To display facebook like with counts in your site is very easy.

First to know how to create an application in facebook.
1)Login in your facebook account.
2)Then go to https://developers.facebook.com/ and click APP menu link.
3)And click + Create New app .
4)Give your App Name (application name) in the popup.
5)After give your site link in Website with Facebook Login and click the save button
6)Now you get the App ID/API Key .




Post this content before </head> in your site.

<head prefix="og: http://ogp.me/ns/fb#">
<meta property="og:title" content="Your site title"/>
<meta property="og:description" content="Your site description" />
<meta property="og:site_name" content="Your site long description"/>
<meta property="og:url" content="http://www.yoursite.com/"/>
<meta property="og:type" content="site" />
<meta property="fb:app_id" content="XXXXXXXXX "/>

Give your application id in the XXXXXXXXX . And place the following code , where you want the fb like and count should be display in your site.

<script>
var fb_js = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=XXXXXXXXX";
(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 = fb_js;
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
  <div class="fb-like" data-href="http://www.yoursite.com/" data-send="false" data-layout="button_count" data-width="450" data-show-faces="true"></div>




Fianlly you get FB like with counts in your site...cheers and enjoy!!!

No comments:

Post a Comment