views:

96

answers:

1

I'm new to the twitter API http://apiwiki.twitter.com/Twitter-API-Documentation and I would like to incentivize users on my website to follow me, or re-tweet me by giving them extra privileges on my site if they do. In order to do this, I need some type of confirmation after they have followed me, or retweeted, etc. Is this possible, or practical? If so can anyone point me in the right direction?

+2  A: 

Yeah, that's reasonable. From their API Documentation (see #1), you can make a followers request, substituting USERNAME with your twitter username:

http://api.twitter.com/1/statuses/followers/USERNAME.xml?cursor=-1

I'd simply store that list of users and, when needed, make periodic new requests to find out if you have additional followers. It looks like it's in order from most recent to newest, so you'd likely only need to request a page or two.

In XPath notation, you'll be interested in the /users/user nodes, and perhaps specifically, /users/user/screen_name[text() = 'provided_username'].

Armed with that information, you can then tweek your website behaviors.

1: "http://apiwiki.twitter.com/Twitter-REST-API-Method:-statuses followers"

Note: markdown seems to break on the space in the above URL, and URL-encoding the space results in a 404.

Kaleb Pederson
Cool, it also looks like there is a created_at field under status relating to when that person followed you. The easiest thing to do would be to assume that no two users will try "following" at the exact same time, and to give them the benefit of a doubt. Thanks for the help Kaleb!
ThinkBohemian
@snowmaninthesun The `created_at` under `user` represents when the user created twitter account where as `created_at` under `status` represents when the tweet was created.
vsr