does somebody knows how to implement facebook like notification? the idea is to put notification on the tabs parallel to the changes made in the database without refreshing the site? if a data is added to the database, the site should react on it. thank you.. cheers!
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Facebook style notifications are achieved in web applications using realtime web technologies such as Comet servers or WebSocket servers. It is possible to add this functionality directly into a PHP application but it's widely agreed that PHP doesn't handle persistent/long-held connections very well (it won't scale). If you still want to host your own realtime PHP solution here are a few resources:
- StackOverflow question about AJAX PHP Push
- phpwebsocket
- Start using HTML5 WebSockets today
- php-websocket
- How to implement Comet in PHP
However, I'd recommend you look at a hosted solution (I work for one such company) which means all you need to do is make a HTTP call to a RESTful API and embed a JavaScript library within your application to achieve your push notifications. More information why I recommend using a hosted service in this SO question on Apache and Comet