CodeworkingJavascriptArticle ≫ Using Facebook API

Using Facebook API

Wed 16 Sep 2015, 06:43

This is my step:

  • Go to
  • Create new apps
  • I’m using Javascript SDK because i think this SDK can be use in any web programming language.
  • This is the code for share, like, and comment:


Add this script to load the SDK:

(function(d, s, id) {
	var js, fjs = d.getElementsByTagName(s)[0];
	if (d.getElementById(id)) return;
  	js = d.createElement(s); = id;
  	js.src = "//[yourAppsId]";
  	fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

Add this for like

<div class="fb-like" data-href="<currentURL>" data-layout="standard" data-action="like" data-show-faces="true"></div>

Add this for share

<div class="fb-share-button" data-href="<currentURL>" data-layout="button_count"></div>

Add this for comment

<div class="fb-comments" data-href="<currentURL>" data-numposts="10"></div>

0 3801 views