How do I test the Facebook "Like" button on localhost?
Asked Answered
I

4

38

It is possible to test "Like" button on localhost?

Ihab answered 29/9, 2011 at 10:31 Comment(0)
G
27

Dave's answer is correct, however, I just discovered a workaround: You can make your local machine accessible by using http://localtunnel.me . You'll need to (temporarily) change some URLs used in your app code / html so links point to the temporary domain, but at least facebook can reach your machine.

Garnetgarnett answered 16/12, 2011 at 14:22 Comment(3)
localtunnel is really convenient to test sharing meta description, title and image.Drawknife
Thanks M.G.Palmer, localtunnel.com works like a charm! Here an announcement about localtunnel version 2: progrium.com/blog/2012/12/25/localtunnel-v2-available-in-beta Github: github.com/progrium/localtunnel/blob/master/README.mdAccumulator
New url: localtunnel.meBlockade
T
28

Not really; facebook has to crawl your site to pull in the title, description, and thumbnail. It can't get to your site if it's on localhost.

True answered 29/9, 2011 at 10:34 Comment(1)
Related to what @M.G.Palmer mentioned, if you can get a public IP address or DNS entry for your local box, and make sure the box is accessible to the outside world, you could use that instead of 'localhost'.True
G
27

Dave's answer is correct, however, I just discovered a workaround: You can make your local machine accessible by using http://localtunnel.me . You'll need to (temporarily) change some URLs used in your app code / html so links point to the temporary domain, but at least facebook can reach your machine.

Garnetgarnett answered 16/12, 2011 at 14:22 Comment(3)
localtunnel is really convenient to test sharing meta description, title and image.Drawknife
Thanks M.G.Palmer, localtunnel.com works like a charm! Here an announcement about localtunnel version 2: progrium.com/blog/2012/12/25/localtunnel-v2-available-in-beta Github: github.com/progrium/localtunnel/blob/master/README.mdAccumulator
New url: localtunnel.meBlockade
A
10

It is possible to perform limited testing on the facebook like button on localhost. It renders properly on my machine. The trick is using a live, non-localhost URL on the data-href attribute (I used Google in the sample below):

<div id="fb-root"></div>
<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/pt_BR/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div class="fb-like" data-href="http://www.google.com" data-width="450" data-layout="button_count" data-show-faces="false" data-send="false"></div>
Arioso answered 14/8, 2013 at 17:9 Comment(0)
W
-4

If you're developing the likebutton for www.xyz.com, just add in your hosts file:

127.0.0.1 www.xyz.com

Hooray, no more 500s.

Wendell answered 20/9, 2013 at 0:53 Comment(1)
This works considering that you already have a website at www.xyz.com with same pages as in your localhost.Adventurism

© 2022 - 2024 — McMap. All rights reserved.