How to add the Facebook Like Button

yet another good chance for me write and share little experience with all of you on How to add the Facebook Like Button on page. Basically there are two different ways we can add facebook like button on page. The second important part is callback fuction for like.

1.I have already shared the details on how to add the like button using iframe. Using the Facebook “Like” iframe now i am going to share second way on how to do this.

2. XFBML and JavaScript SDK
It will be better to use Facebook’s JavaScript SDK since you’ll need it to implement other features anyway.
while integration use the same configuration tool as with the iframe and select the XFBML code and place it in your page template. Now let me explain what we can do with following code. copy meta statement from following code and past them into header portion of the page and the second part, that is copy “fb:like” tag add it to the place you want. Now the javascript should be before the body tag ends. it has two things. one is just to init the facebook and second section is “FB.Event.subscribe” is to catch the facebook like button callback event.

Share this nice post: