Add following javascript code which are Responsible for load javascript SDK.
window.fbAsyncInit = function() { FB.init({ appId : FB_APP_ID, cookie : true, xfbml : true, version : 'v2.3' }); }; (function(d){ var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;} js = d.createElement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_US/all.js"; d.getElementsByTagName('head')[0].appendChild(js); }(document));Please don't forget to replace the "FB_APP_ID" with facebook API Id.
Add following javascript code which will leverage the functionality like Login check, login details, Share URL and Post to facebook.
function fbLogin(){ FB.getLoginStatus(function(response) { if (response.status === 'connected') { console.log('You are login in FB.'); } else { FB.login(); } }); } function fbLoginDetails(){ FB.api('/v2.2/me?fields=name,email,location,gender,birthday', function(response) { console.log(response.toSource()); }); } function fbShareURL(){ FB.ui( { method: 'share', href: 'http://www.web-technology-experts-notes.in/2013/09/Facebook-Registration-Plugin-with-Custom-Fields.html' }, function(response){ }); } function fbPostURL(){ FB.ui({ method: 'share_open_graph', action_type: 'og.likes', action_properties: JSON.stringify({ object:'http://www.web-technology-experts-notes.in/2013/09/Facebook-Registration-Plugin-with-Custom-Fields.html', }) }, function(){}) }
Add following HTML code which will create button on which click functionality will work.
Facebook Login Check Facebook Get Login Details Facebook Share URL Facebook POST URL