Facebook Like Button Dislikes My Code
Asked Answered
J

3

6

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

Junina answered 6/7, 2011 at 2:29 Comment(0)
E
1

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=

Euglena answered 6/7, 2011 at 2:39 Comment(1)
Just tested on my Rackspace server and I'm having the same problemJunina
Q
0

I've had problems testing the like on sites using temp urls - Facebook doesn't like it when the associated app_id value is not related to the url of the page you're trying to like. But I could be wrong. If you temporarily expand the width to something beyond 50 (like 300-350), there should be an "error" link that pops up that will give you some more valuable information...

Quadrature answered 6/7, 2011 at 2:37 Comment(0)
P
0

If you use fbml then you will not need the application ID. Using fbml you can configure several things. I think you already have a look at-

http://developers.facebook.com/docs/reference/plugins/like/

You can try the following code

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

Then in the body

<div id="fb-root"></div>
<fb:like href="http://yoururl" send="true" width="450" show_faces="true" font="">
</fb:like>
Palaeolithic answered 6/7, 2011 at 5:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.