简体   繁体   English

Django:Facebook评论整合

[英]Django: Facebook comments integration

I want Facebook comments integration on Django site, what should I use to integrate Facebook comments into a page? 我想在Django网站上集成Facebook评论,我应该用什么来将Facebook评论整合到一个页面中?

Thanks, 谢谢,

Sultan 苏丹

It can be done via javascript. 它可以通过javascript完成。 Just add the Facebook SDK and add the comments at the bottom of your template. 只需添加Facebook SDK并在模板底部添加注释即可。 Just make sure to have some sort of slug to uniquely identify the page 只要确保有一些slug来唯一标识页面

<body>
<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
  FB.init({
    appId      : 'YOUR_APP_ID', // App ID
    channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
    status     : true, // check login status
    cookie     : true, // enable cookies to allow the server to access the session
    xfbml      : true  // parse XFBML
  });
};

(function(d){
  var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement('script'); js.id = id; js.async = true;
  js.src = "//connect.facebook.net/en_US/all.js";
  ref.parentNode.insertBefore(js, ref);
}(document));
</script>

...

<div
   class="fb-comments" 
   data-href="{{ my_object.slug }}" 
   data-num-posts="2" 
   data-width="470"></div>

https://developers.facebook.com/docs/reference/plugins/comments/ https://developers.facebook.com/docs/reference/plugins/comments/

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

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