问题
It is possible to test "Like" button on localhost?
回答1:
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.
回答2:
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.
回答3:
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>
回答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.
来源:https://stackoverflow.com/questions/7595989/how-do-i-test-the-facebook-like-button-on-localhost