Comments with Facebook for different news on site

0

I'm developing a website that will have several different posts (like a blog, for example). I added the comment plugin with Facebook, so that users who access can comment. However, I'm in the following situation:

The user accesses a news story: nomedosite.com/noticias?id=1

The news is displayed and at the end the comment system is displayed. When the user comments, the comment is saved. But when opening another news:

nomedosite.com/noticias?id=2

, comments from the previous news appear together. I need every news item to have its 'line' of comments. How can I do this?

    
asked by anonymous 31.03.2016 / 21:33

2 answers

2

Good morning .. It is very easy to solve the problem you are having. In the Facebook API there is a parameter to be passed in the code that you lock that object from the comments with the URL you decide.

If your site has a news item that is in the URL link , in the code you will implement like this:

<div class="fb-comments" data-href="http://meusitebacana.com/noticia-2" data-numposts="5">
</div>

Where data-href will set to facebook which news url you want the comments to be.

In PHP, in the course of programming, you write that url there.

It's important to note that: This URL can not be dynamic, so if you put it like this: $url = "http://".$_SERVER["SERVER_NAME"]."/".$_SERVER["REQUEST_URI"]; and the person access http://meusitebacana.com/noticia-2?utm_source=google , the URL will look different and the comments will also be another. Then there will be duplication of comments to a single URL (which is not what you expect).

The Facebook API mounts the code for you, just log in.

I hope I have helped.

    
01.04.2016 / 13:31
-2

To implement Comments, you need 3 things, first is the Open Graph, to set the properties of the page that will be commented, including, eventually, canonical URL. Second, it is the Facebook SDK. Third, the markup element of the Plugin. In this element, you must specify the object or the URL that will be commented by this plugin. If this element is outside a structure, for example: There is a product inside the page, which has a head and footer. If you put it inside the dynamic content of the product, with the specified URL, it will work every time one. But you can also have one in the footer, specifying any of the URLs you prefer. Remembering that TO COMMENT SOMETHING, YOU MUST KNOW WHAT SHALL BE COMMENTED, because the plugin is not simply a tool for collecting comments and displaying them. It generates activities within Facebook, very significant for the performance of content distribution. In case news should be categorized as type news. And should contain information about date of publication, as well as the author. There are several other details to implement the comments, you should look for Open Graph before and after the Like and Share for Sites button.

    
23.10.2018 / 09:08