Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook comments plugin using GraphAPI

I've been searching for an answer but I find that is hard to find something conclusive about this in the docs (it's entirely possible that I have missed something).

Background

I'm using this plugin to display the comments on my site and I'm trying to add a "realtime" feature. I'm aware that Facebook doesn't provide a auto-refresh feature for the plugin by "default" like they do on their site, so I'm emulating that via ajax requests in a setInterval() function.

Question

Is there a way to implement a long ajax pulling, push or another (better?) solution to get the comments information?, The multiple ajax request solution works fine, but it's a little consuming.

Thanks a lot!

like image 554
nicosantangelo Avatar asked Nov 13 '22 18:11

nicosantangelo


1 Answers

Generally you can achieve what you want by using WebSockets, however I do not think that Facebook supports a WebSockets based mechanism for their API, therefore there is probably no solution that doesn't include some kind of polling. However, you can move that polling mechanism from the user's browser to your server, which would probably make for a better user experience and reduces the number of API calls you have to make to the Facebook API, in case there are rate limits on that.

More specifically I am suggesting a mechanism where you poll the data from the Facebook API into your database, then setup a WebSockets solution such as Socket.IO which delivers the data polled from the Facebook API using the WebSockets event-driven (that is, much faster than polling) mechanism to the user of your website (Socket.IO falls back to AJAX polling if the user's browser does not support WebSockets).

like image 73
fresskoma Avatar answered Nov 15 '22 10:11

fresskoma