Facebook comment plugin using GraphAPI

I searched for the answer, but found that it was difficult to find something convincing in the document in the documents (it is quite possible that I missed something).

Background

I use this plugin to display comments on my site, and I'm trying to add a real-time feature. I know that Facebook does not provide an automatic update function for the plugin by default, as on its website, so I emulate this through ajax requests in the setInterval() function.

Question

Is there a way to implement a long ajax pulling, push, or another (better?) Solution to get information about comments ?, Multiple ajax request solution works fine, but it consumes a bit.

Thanks a lot!

+4
source share
1 answer

You can usually achieve what you want using WebSockets , however I don’t think Facebook supports a mechanism based on using WebSockets for their APIs, so there probably isn’t a solution that doesn’t include any kind of poll. However, you can transfer this polling mechanism from the user browser to your server, which will probably create a more convenient user interface and reduce the number of API calls that you must make to the Facebook API if there are speed limits.

In particular, I propose a mechanism in which you query the data from the Facebook API in your database, then configure a WebSockets solution, such as Socket.IO , which provides the data polled in the Facebook API using the event-driven WebSockets mechanism (i.e. much faster than polling) for the user of your site (Socket.IO returns to AJAX polling if the user's browser does not support WebSockets).

+1
source

Source: https://habr.com/ru/post/1443493/


All Articles