Is there any way for the Google App Engine's urlfetch to open and keep open a Twitter Streaming API connection?

StackOverflow https://stackoverflow.com/questions/972781

  •  13-09-2019
  •  | 
  •  

Question

The Twitter streaming api says that we should open a HTTP request and parse updates as they come in. I was under the impression that Google's urlfetch cannot keep the http request open past 10 seconds.

I considered having a cron job that polled my Twitter account every few seconds, but I think Google AppEngine only allows cron jobs once a minute. However, my application needs near-realtime access to my twitter @replies (preferably only a 10 second or less lag).

Are there any method for receiving real-time updates from Twitter?

Thanks!

Was it helpful?

Solution

Unfortunately, you can't use the urlfetch API for 'hanging gets'. All the data will be returned when the request terminates, so even if you could hold it open arbitrarily long, it wouldn't do you much good.

Have you considered using Gnip? They provide a push-based 'web hooks' notification system for many public feeds, including Twitter's public timeline.

OTHER TIPS

I'm curious.

Wouldn't you want this to be polling twitter on the client side? Are you polling your public feed? If so, I would decentralize the work to the clients rather than the server...

It may be possible to use Google Compute Engine https://developers.google.com/compute/ to maintain unrestricted hanging GET connections, then call a webhook in your AppEngine app to deliver the data from your compute engine VM to where it needs to be in AppEngine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top