Comments with Facebook for different news on site

I am 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 am in the following situation:

The user accesses a news: 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 story to have its' line ' of comments. How can I do that?

Author: Developer1903, 2016-03-31

2 answers

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 comment object with the URL you decide.

If your site has a news item that is in the URL http://meusitebacana.com/noticia-2 , in the code you will implement like this:

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

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

No PHP, in the course of programming, you write this url there.

It is important to emphasize that: this URL can not be dynamic, and if you set it up like this: $url = "http://".$_SERVER["SERVER_NAME"]."/".$_SERVER["REQUEST_URI"]; and the person accessing http://meusitebacana.com/noticia-2?utm_source=google, the URL will be different and the object of the comments will also be different. Then there will be duplicity of comments to a single URL(which is not what you expect).

The Facebook API assembles the code for you, just access.

I hope I helped.

 2
Author: Whatyson Neves, 2016-04-01 11:31:18

To implement comments, you need 3 Things, First is the Open Graph, to define the properties of the page that will be commented, including eventually Canonico URL. Second, it's 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: It has a product inside the page, which has head~lho and footer . If you putting it inside the dynamic content of the product, with the specified URL, will work every time. But you can also have one in the footer, specifying any of the URLS you prefer. Remembering that to comment something, you should know what will be commented, Because the plugin is not simply a tool to collect comments and display them. It generates activities within Facebook, very significant for the performance of content distribution. In case news should be categorized as like news. And it should contain information about the date of publication, as well as from the author. It has several other details, to implement the comments, you must search Open Graph before and after the like and Share button for sites .

 -2
Author: David Augustus, 2018-10-23 07:08:44