Parsing Facebook comments

Discussion in 'HTML & Website Design' started by ultimalite, Sep 3, 2011.

  1. #1
    I have a question.

    I am trying to use facebook comments plugin.
    has anyone here used it?

    when you install this plugin, all comments are displayed in an iframe, which is not accessible by search engine bots.
    Facebook suggests to grab the comments with a special PHP code and render them in the body of HTML page behind the comments box.

    That's the code:

    <?php 
    
       $url = "http: //developers.facebook.com/blog/post/472";
    
       $request_url ="https: //graph.facebook.com/comments/?ids=" .
            $url;
    
        $requests = file_get_contents($request_url);
    
        print "<PRE>";
        print_r($requests);
        print "</PRE>";
    
    ?>
    PHP:


    When I do it, all comments appear twice (obviously) on my page.
    First: normal comments box

    Second: huge line of comments that looks like:

    but 100 times longer.

    If I hide these rendered comments within a hidden div or use any other way to hide then from users while keeping them accessible by search bots, it will be considered a bad SEO practice and this URL will be most likely penalized.

    Do you have any idea what I should do?
    Anyone who actually used Facebook comments plugin rendered comments?
    How did you guys deal with this situation?
    Is hiding content indeed such a bad thing in terms of SEO?

    Thank you!
     
    Last edited: Sep 3, 2011
    ultimalite, Sep 3, 2011 IP
  2. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #2
    We need to see the logic. Is this AJAX or are you creating the HTML in the PHP? (It looks as if you have 2 places in the page that call the PHP file, once in the comments box and once somewhere else.)
     
    Rukbat, Sep 3, 2011 IP
  3. ultimalite

    ultimalite Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Here's what I do.


    I have my http://example.com/page_one.php

    This is my HTML page with the content.


    I added FB comment plugin to the code of my page.

        <div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:comments href="http://example.com/page_one.php" num_posts="10" width="500"></fb:comments>
    Code (markup):
    At this point comments are visible to the user but are invisible to search engines.

    Then I added the PHP code to the code of my page, just below the first code

    <?php 
    
       $url = "http://example.com/page_one.php";
    
       $request_url ="https://graph.facebook.com/comments/?ids=" .
            $url;
    
        $requests = file_get_contents($request_url);
    
        print "<PRE>";
        print_r($requests);
        print "</PRE>";
    
    ?>
    Code (markup):
    So now the comments appear twice.

    I placed the PHP code inside a div and I styled this div with CSS so that the comments look small but it's still wrong.






     
    ultimalite, Sep 3, 2011 IP
  4. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #4
    Run Firefox with Firebug and FirePHP. Add
    fb::log($requests);
    Code (markup):
    just before print "</PRE>"; (and the initial lines to get FirePHP loaded). Then you'll see what you're getting in $request and you can parse out what you need. Once it's clean, you can put it anywhere on the page you like. (And comment out the whole fb-root div.)
     
    Rukbat, Sep 3, 2011 IP
  5. ultimalite

    ultimalite Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    thanks, but I'm just not sure about the whole concept now. How can FB suggest something that creates double content on the page?
    Even if I only parse partial comments, it's still double content, which is not logical at all and confusing.


     
    ultimalite, Sep 3, 2011 IP
  6. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #6
    They're giving you content - you're causing it to be displayed twice.
     
    Rukbat, Sep 3, 2011 IP
  7. ultimalite

    ultimalite Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    The problem is now solved. Thank you.
     
    ultimalite, Sep 4, 2011 IP
  8. trebomedia

    trebomedia Active Member

    Messages:
    132
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #8
    When you go to FB for the plugin code you need to fill in a webadress. What should I fill in to have a separate commentbox on each page. When I fill in my domain name it and comment on a page, then youll see the comment in the commentbox on every page.

    Thanks!
     
    trebomedia, Sep 5, 2011 IP