简体   繁体   English

Facebook使用GraphAPI评论插件

[英]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. 我知道Facebook没有像他们在网站上那样通过“默认”为插件提供自动刷新功能,所以我通过setInterval()函数中的ajax请求来模拟它。

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. 有没有办法实现一个长ajax pull,push或另一个(更好?)解决方案来获取注释信息?,多个ajax请求解决方案工作正常,但它有点消耗。

Thanks a lot! 非常感谢!

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. 通常,您可以通过使用WebSockets实现您想要的功能,但我不认为Facebook支持基于WebSockets的API机制,因此可能没有不包含某种轮询的解决方案。 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. 但是,您可以将该轮询机制从用户的浏览器移动到您的服务器,这可能会带来更好的用户体验,并减少您必须对Facebook API进行的API调用次数,以防速率限制。

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). 更具体地说,我建议一种机制,您将Facebook API中的数据轮询到您的数据库,然后设置一个WebSockets解决方案,如Socket.IO ,它使用WebSockets事件驱动提供从Facebook API轮询的数据(即,对您网站用户的机制(轮询速度快)(如果用户的浏览器不支持WebSockets,Socket.IO会回退到AJAX轮询)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM