How to integrate the Facebook comment plugin, in my website?

Discussion in 'PHP' started by eritrea1, Jul 24, 2012.

  1. #1
    Hi, Guys

    I need to include the comment plugin for my site, I have actually done this once, but it was manually. Like, below a set of text, I just placed the comment plugin, I had copied from my page, and it worked. But, this time I am working on is a dynamic site, and with new articles posted on the site, I need a comment box to appear below it.


    txs :)
     
    eritrea1, Jul 24, 2012 IP
  2. SentoWeb

    SentoWeb Active Member

    Messages:
    189
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    80
    Digital Goods:
    3
    #2
    Place the following code in the header:

    http://developers.facebook.com/docs/reference/plugins/comments/ will generate a similar code with application id.

    <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&appId=[Application ID]";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>
    Code (markup):
    ... and add the following where you want the actual commenting system to appear:

    <div class="fb-comments" data-href="<?=$url_of_page;?>" data-num-posts="2" data-width="470"></div>
    Code (markup):
    The only variable which has to be edited is the data-href attribute of the div however you can easily build the link of the current page. (file.php?id=$_GET["id"]&stm=$_GET["stm"])
     
    SentoWeb, Jul 24, 2012 IP
  3. vitabion

    vitabion Peon

    Messages:
    306
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    WoW this one is good stuff.
    It's really helpful for me. Thanks a lot dude .
     
    vitabion, Jul 25, 2012 IP