问题
My problem is, that the like button is not showing, when I try to run it local. On JSfiddle it works, I don't understand why.
JSFiddle: http://jsfiddle.net/fmzu6738/
With the code I want to achieve, if I click the like button, I like the page and the page automatically redirect to the facebook side
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://ogp.me/ns/fb#">
<head>
<title>bla</title>
</head>
<body>
<div id="Div1">
</div>
<script type="text/javascript">
(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/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
} (document, 'script', 'facebook-jssdk'));</script>
<div id="fb-root">
</div>
<fb:like href="https://www.facebook.com/Bxyz" send="true" show_faces="false" data-layout="button" data-action="like" data-show-faces="false" data-share="false">
</fb:like>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
status: true, // check login status
cookie: true, // enable cookies to allow the server to access the session
xfbml: true // parse XFBML
});
</script>
<script type="text/javascript">
FB.Event.subscribe('edge.create', window.location.href = "https://www.facebook.com/xyz";);
</script>
</body>
</html>
What is wrong here? Thank you very much!
回答1:
Facebook api requires HTTP Server like "apache, IIS, etc.." make sure you'r working local-server like "xammp, apache, mamp for mac"
来源:https://stackoverflow.com/questions/25856560/like-button-not-showing-except-jsfiddle