帮助建立一个流(或推)API与PHP和Apache [英] Help creating a streaming (or push) API with PHP and Apache

查看:120
本文介绍了帮助建立一个流(或推)API与PHP和Apache的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个项目我工作的一个API,允许开发人员创建桌面和围绕它的功能内置移动应用。有一件事我一直想学习如何做的是创造一个无状态的,推送通知系统,类似于Twitter的流API。

I'd like to create an API for a project I'm working on, allowing developers to create desktop and mobile applications built around its functionality. One thing I've always wanted to learn how to do is create a stateless, push notification system, similar to Twitter's Streaming API.

基本上,我希望能够在实时的任何变更的用户通知的数据,或接近它作为可能的。我知道,这可能是很难在移动设备上,这就是为什么移动应用将可能建成以检查更新周期,以节省电池。但是,桌面应用程序不会再有这样的限制。我想避免的应用程序向服务器是否有新的信息,而是让服务器告诉应用程序有新的数据。

Basically, I want to be able to notify users of any changes to the data in real time, or as close to it as possible. I know that this might be difficult on mobile devices, which is why mobile applications will probably be built to check for updates periodically, to save battery. However, desktop applications won't have that limitation. I'd like to avoid making the application ask the server if there is new information, and instead let the server tell the application that there is new data.

我的编程语言是PHP和我的服务器是Apache的。如果我绝对必须,我可以切换到lighttpd的nginx的或,但是这是一个绝对的最后一招,因为它需要很多的变化,以现有的所有code的。

My programming language is PHP and my server is Apache. If I absolutely had to I could switch to Lighttpd or nginx, but that's an absolute last resort since it would require a lot of changes to all of my existing code.

我读过这篇文章:

http://www.zeitoun.net/articles/comet_and_php/start

和测试出来,但不幸的是所发生的一切是我的浏览器不断尝试加载页面,并没有实际显示时间。我怀疑这是因为,无论什么原因,我从来没有能够得到输出缓冲到我的服务器上运行,除非我发送数据的64KB(或更多)。听说我不得不禁用它,我做到了,它仍然没有工作,所以我不知道。

And tested it out, but unfortunately all that happens is my browser keeps attempting to load the page and never actually displays the time. I suspect this is because, for whatever reason, I've never been able to get output buffering to work on my server, unless I send 64kb (or more) of data. I heard that I had to disable gzip, which I did, and it still didn't work, so I don't know.

推荐答案

看一看一些现有的技术来帮助你做到这一点:

Have a look at some existing technologies to help you do this:

旋风

龙卷风是可扩展的,无阻塞的网络服务器和工具,权力的FriendFeed的开源版本。 FriendFeed的应用程序使用的Web框架,看起来有点像web.py或者谷歌的Web应用程序,但与其他工具和优化,以便利用基本无阻塞的基础设施优势编写的。

Tornado is an open source version of the scalable, non-blocking web server and tools that power FriendFeed. The FriendFeed application is written using a web framework that looks a bit like web.py or Google's webapp, but with additional tools and optimizations to take advantage of the underlying non-blocking infrastructure.

推杆是快速托管API,轻松且安全地通过WebSockets向网络和移动应用添加可扩展实时功能。

Pusher is a hosted API for quickly, easily and securely adding scalable realtime functionality via WebSockets to web and mobile apps.

两者都是非常快的,可扩展的,并且我已经安装都比较容易。

Both are extremely fast and scalable, and I have setup both relatively easily.

这篇关于帮助建立一个流(或推)API与PHP和Apache的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆