Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Like Button Dislikes My Code

I've been trying to implement a Facebook Like button on my blog like this:

$("#fblike").append(" <iframe src='http://www.facebook.com/plugins/like.php?app_id=217624258276389&amp;" + window.location.href + "&amp;send=false&amp;layout=box_count&amp;width=50&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=60' scrolling='no' frameborder='0' style='border:none; overflow:hidden; width:50px; height:60px;' allowTransparency='true'></iframe>");

And adding this to the <head> of my HTML source file:

<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>

The problem is that when I try to test the Like button it shows 1 instead of 0 and a second later goes back to 0. Nothing changed at my Facebook profile neither. What's wrong and how to correct this?

PS: I'm running this on a localhost server, in my case http://nathan-camposs-macbook-pro.local/~Nathan

like image 206
Nathan Campos Avatar asked Jul 06 '11 02:07

Nathan Campos


People also ask

Why is my Like button not working on Facebook?

It might be because you have liked a lot and too many photos and posts. As you might already not know, Facebook has a limit for their likes and other actions (such as follow, unfollow). If you exceed the limits (which are not clear) you will be temporarily action blocked.

Why did FB change the Like button?

"We are removing Likes and focusing on Followers to simplify the way people connect with their favourite Pages," Facebook said about the redesign. The notable changes include a redesigned layout, News Feed, easy navigation, updated task-based admin controls, actionable insights, and safety features.

How do I activate Like button?

Go to Settings › General, then click the Share tab. Enable the Facebook Like/Recommend button setting by clicking the “thumb up” Like icon.


1 Answers

I think the events go something like:

  1. You click the button.
  2. Javascript sends the like request to FB.
  3. Facebook tries to access your page ("localhost").
  4. It can't access it so the request is denied.

UPDATE:-

I noticed that your src attribute starts: 'http://www.facebook.com/plugins/like.php?app_id=217624258276389&amp;" + window.location.href + "&amp;

i think it should be: 'http://www.facebook.com/plugins/like.php?app_id=217624258276389&amp;href=" + window.location.href + "&amp;

notice the href=

like image 116
James Khoury Avatar answered Sep 19 '22 08:09

James Khoury