Hi, I'm in the process of trying to integrate Twitter into a web app
I'm building.  The application is a Ruby on Rails app (my first).
I've reviewed some of the Twitter API docs and have a general idea of
what options are available and wanted to ask some questions to clarify
some fuzzy areas.  First, let me explain what I'd like to accomplish.

Users of my app will be able to indicate that they want any of their
tweets with hashtags to appear on my site as messages posted from that
user.  So, if I were a user who had selected this option and tweeted
"I like #foo", this site would see that tweet and add the same message
to their site.  This is essentially so that people don't have to
actually directly use my app to use it.  Instead, they just tweet
stuff and my app picks it up (so long as it has a hash tag).

Secondary to that, a nice-to-have feature would be to know when a
twitter user follows or unfollows another twitter user.  I'd like my
app to see if the followed or unfollowed user is using my service as
well and to automatically follow or unfollow them in my app.

My question is, which of the APIs should I use?  I see that there are
three streaming APIs:

- Streaming API.

I think this is basically a way I could have my app connect to twitter
and listen for tweets from users of my service.  I know you can filter
the stream, for example to my web apps' users.  However, what if I
have a *lot* of twitter users I want to filter to?  Like tens or
hundreds of thousands of users?  I don't have this problem now (and
may never) but I'd like to know if this is still what I should be
looking at.  If there are lots of twitter users I'm listening for
tweets from should I still have only one stream connection open or
multiple?  What is a general best practice for this?

Also, I get the impression that the streaming API is essentially a
stream of the same public information that's available to any twitter
user.  Given that, I'm unsure if this API includes follow and unfollow
information.  It seems like this may be the easiest of the APIs to
implement.

- User Stream

I'm pretty sure this is intended for desktop clients like TweetDeck.
It's a one-user per connection stream.  I'm pretty sure Twitter
doesn't want me potentially making tens or hundreds of thousands of
individual connections to their stream.  So, I'm pretty sure this is
out.

- Site Stream

This appears to be very similar to User Stream, but, as the docs say,
it allows you multiplex several user streams over one streaming
connection.  This may be another option I want to consider.  I know
that it will let me see multiple twitter user's tweets on one
connection.  I think it will let me get notices of follows and
unfollows (meeting my second nice-to-have feature needs).  The thing
is, I'm unclear on if I would use one connection for ALL of my users
or multiple connections, pooling several (I don't know how many) users
into each.  I saw in the docs details about how some connections
should be merged, etc, over time given certain conditions.  That's a
bit beyond where I am at the moment.

Also, I see that this is a private beta you can apply to join.  They
also say to implement User Stream before applying.  That's all fine
and dandy, I'm happy to do both.  But, at the same time, User Streams
is a one-user-per-connection arrangement, right?  It doesn't match my
use case and seems, well, like the wrong thing to do.  Can anyone
offer any guidance on this?

- One other idea I had.

What if I simply setup a twitter account for my app?  I could then use
the standard twitter API to have this account follow and unfollow
twitter users based on their preferences in my app.  And, perhaps,
from there I could somehow (via user stream?) feed posts from those
users my app is following into my app.  I'm a bit concerned that this
may simply be a hack and maybe even violate twitter's TOC.

So, overall, I'm just looking for a bit of guidance out of the gate on
where to start research and work.  Also, if you know of any quality
Ruby gems that implement the approach you suggest, I'd love to hear
about them.

Thanks for your help,

Doug Hughes

-- 
Twitter developer documentation and resources: https://dev.twitter.com/doc
API updates via Twitter: https://twitter.com/twitterapi
Issues/Enhancements Tracker: https://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
https://groups.google.com/forum/#!forum/twitter-development-talk

Reply via email to