我无法让 Facebook Like 按钮在 ASP.NET 页面上工作。我尝试使用 FB 开发人员工具生成代码以显示点赞按钮,也尝试使用 AddThis,但均无效。以下是我尝试过的事情:
1) 类似按钮生成器的FB生成,IFRAME风格
<html>
<body>
<iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.illuminephotos.co.uk%2Fblog.aspx&send=false&layout=standard&width=450&show_faces=true&action=like&colorscheme=light&font=segoe+ui&height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>
</body>
</html>
2) 类似按钮生成器的FB生成,HTML5风格
<html>
<body>
<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/en_GB/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
} (document, 'script', 'facebook-jssdk'));</script>
<div class="fb-like" data-href="http://www.illuminephotos.co.uk/blog.aspx"
data-send="false" data-width="450" data-show-faces="true" data-font="segoe ui"></div>
</body>
</html>
3) 由 AddThis 生成(稍微修改了<%=...%>
块以使其在 ASP.NET 上工作)
<html>
<body>
<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style ">
<a class="addthis_button_facebook_like" <%="fb:like:layout"%>="button_count"></a>
<a class="addthis_button_tweet"></a>
<a class="addthis_button_google_plusone" <%="g:plusone:size"%>="medium"></a>
<a class="addthis_counter addthis_pill_style"></a>
</div>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4f4c14fd1002be4d"></script>
<!-- AddThis Button END -->
</body>
</html>
在这两种情况下,1) 和 2) 在 localhost 上都能完美运行。我可以看到 Like 按钮,当我单击它时它会起作用。但在服务器上,什么都没有,Firebug 的网络控制台只显示“blog.aspx”的获取,没有别的。
在 localhost 3) 上也可以完美运行,我可以看到 FB、Twitter、G+ 和 AddThis 按钮。但在服务器上,只有 Twitter、G+ 和 AddThis,没有 FB。
我已经用谷歌搜索并搜索过,但我很难过。Facebook 在做什么,而 Twitter/G+ 却没有?有任何想法吗?它如何在本地主机上正常工作但在服务器上失败?