Realtime Twitter Replies?

Posted by ejunker on Stack Overflow See other posts from Stack Overflow or by ejunker
Published on 2010-03-24T16:19:15Z Indexed on 2010/03/24 16:33 UTC
Read the original article Hit count: 299

Filed under:
|
|

I have created Twitter bots for many geographic locations. I want to allow users to @-reply to the Twitter bot with commands and then have the bot respond with the results. I would like to have the bot reply to the user as quickly as possible (realtime).

Apparently, Twitter used to have an XMPP/Jabber interface that would provide this type of realtime feed of replies but it was shut down.

As I see it my options are to use one of the following:

REST API

This would involve polling every X minutes for each bot. The problem with this is that it is not realtime and each Twitter account would have to be polled.

Search API

The search API does allow specifying a "-to" parameter in the search and replies to all bots could be aggregated in a search such as "-to bot1 OR -to bot2...". Though if you have hundreds of bots then the search string would get very long and probably exceed the maximum length of a GET request.

Streaming API

The streaming API looks very promising as it provides realtime results. The API allows you to specify a follow and track parameters. follow is not useful as the bot does not know who will be sending it commands. track allows you to specify keywords to track. This could possibly work by creating a daemon process that connects to the Streaming API and tracks all references to the bot's names. Once again since there are lots of bots to track the length and complexity of the query may be an issue. Another idea would be to track a special hashtag such as #botcommand and then a user could send a command using this syntax @bot1 weather #botcommand. Then by using the Streaming API to track all references to #botcommand would give you a realtime stream of all the commands. Further parsing could then be done to determine which bot to send the command to.

Third-party service

Are there any third-party companies that have access to the Twitter firehouse and offer realtime data?

I haven't investigated these, but here are a few that I have found:

I'm leaning towards using the Streaming API. Is there a better way to get near realtime @-replies for many (hundreds) of Twitter accounts?

© Stack Overflow or respective owner

Related posts about twitter

Related posts about twitterapi