将 Google 的 Channel API 与 Twitter 的 Streaming API 结合使用
我正在尝试使用 Google 的 App Engine 和 Twitter 的流 API(使用 twitter4j)来创建一个应用程序,我可以在其中输入一个单词,它将在页面上“实时”显示带有该单词的推文。
我已经有很多 Java 代码来处理推文,并且我正在尝试将我的代码放在 App Engine 上。我猜最好的方法是使用 Google 的 ChannelAPI。是这样吗?
据我所知,twitter4j 创建一个线程来处理通过的推文,而 GAE 不支持这样的线程。
是否可以让服务器在推文可用时将推文推送到客户端,就像 Comet 一样?
我已经寻找了很长时间试图找到一些相关的指南,但还没有找到。因此,如果有人知道的话,那就太好了。
I'm trying to use Google's App Engine with Twitter's streaming API (using twitter4j) to make an application where I can type in a word and it will display the tweets with that word in 'real time' on the page.
I already have a lot of Java code to deal with the tweets, and I'm trying to put my code on the App Engine. I'm guessing the best way to do this would be with Google's ChannelAPI. Is that right?
I understand that twitter4j creates a thread to handle the tweets that come through, and GAE doesn't support threads like this.
Is it possible to have the server push tweets to the client as they become available, like with Comet?
I've been searching for ages trying to find some relevant guides but haven't yet found any. So if anyone knows any, that would be great.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据这篇 twitter4j 博文,twitter4j 与 Google App Engine 兼容。我建议您确保使用该博客文章中链接的版本 2.0.1。
您说的也对,Google App Engine 不支持线程。
对于实时组件,您还应该查看此 ChannelAPI 演示。它展示了 ChannelAPI 如何基本上将信息从服务器推送到客户端。
According to this twitter4j blog post, twitter4j is compatible with Google App Engine. I suggest you make sure you're using the version 2.0.1 linked from that blog post.
You are also correct that Google App Engine doesn't support threads.
For the real-time component, you should also look at this ChannelAPI Demo. It shows how the ChannelAPI can basically push information from the server to the client.