简体   繁体   English

Facebook点赞按钮

[英]Facebook Like button

i'm trying to integrate facebook like button with every post that i read from db. 我正在尝试将db之类的facebook集成到我从db中读取的每个帖子中。

I got the code from https://developers.facebook.com/docs/reference/plugins/like/ . 我从https://developers.facebook.com/docs/reference/plugins/like/获得了代码。 after i put this script in header 我把这个脚本放在标题后

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

i've put this code where i need then edited the link 我将这段代码放在需要的地方,然后编辑了链接

<div class="fb-like" data-href="http://localhost/post.php?id=<?php echo $_GET['id']; ?>" data-send="false" data-width="450" data-show-faces="true"></div>

now it looks ok. 现在看起来还可以。 ( http://i.imgur.com/7om8PC9.png ). http://i.imgur.com/7om8PC9.png )。 So i hit the like button ( http://i.imgur.com/QIkVc7d.png ) but after refresh it disappears ( http://i.imgur.com/llquzKH.png ). 因此,我按下了“赞”按钮( http://i.imgur.com/QIkVc7d.png ),但是刷新后它消失了( http://i.imgur.com/llquzKH.png )。 My question is, what i'm doing wrong and what should i do in order to get those likes stored? 我的问题是,我做错了什么,应该怎么做才能保存那些喜欢的东西? Thanks. 谢谢。

You can't use an internal URL like http://localhost/ in a Facebook like. 您不能在Facebook之类的网站中使用内部URL,例如http://localhost/ The like won't get stored. 像不会被存储。

If you are developing locally, it is possible that Facebook will not register your like since it can not access the page you are liking. 如果您在本地开发,Facebook可能无法注册您的喜欢的图片,因为它无法访问您喜欢的页面。 If this is your problem, this is perfectly normal and will resolves itself when you put your site online. 如果这是您的问题,那是完全正常的现象,当您将网站置于在线状态时,它会自行解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM