AriyankiNet        
 


CodeworkingJavascriptArticle ≫ Using Facebook API

Using Facebook API

Wed 16 Sep 2015, 06:43


This is my step:

  • Go to https://developers.facebook.com/
  • 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:

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

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 289 views