Search code examples
facebookcommentsfacebook-social-pluginsxfbmlfacebook-comments

Facebook feed link back to article not working for Facebook Comments implemented on custom CMS


I implemented facebook comments across a legacy, custom CMS. I used the XFBML implementation. Everything works as expected except when clicking the links back to the article page from a commenter's facebook feed the comment box does not show any comments. The link is of this form:

{Article URL}?fb_comment_id={comment_id_string}

And if I remove the comment parameter and only go to the article url the comment box renders correctly with the comment and all other comments on the article. So, it's some issue with the fb_comment_id parameter. One weird thing about how I had to implement the comments is, because of how the routing on the site works, I could not use server side code to set the the URL parameter in the <fb:comments> object. So I had to use this jquery code in the <head>:

<script>
        // assign current page to comments url
        $(document).ready(function() {
            $('fb\\:comments').each(function(){
                $(this).attr('href', window.location);
            });
        });
</script>

And used this for the actual <fb:comments> code:

<fb:comments href="{site's root URL}" num_posts="8" width="570"></fb:comments>

So, I figure doing this client side may be causing the issue. Not doing this server side is a hard constraint though, and everything else works so I'm hopeful there may be some way to make this work. If making the comment link work correctly is impossible, a reasonable hack would be to rewrite the link in the facebook feed so that it just points to the article url without adding the comment parameter. Any suggestions? Thanks!

NOTE: I've also tried using the html5 comments implementation and there is the same issue.;


Solution

  • Once facebook has rendered the iframe based upon your fb:comments tag, does it have the correct url? I am thinking it does not. You may have to call FB.XFBML.parse() after you inject the complete