tbleckert
tbleckert

Reputation: 3801

Twitter api - trigger on new post?

I have never worked with the twitter api, so I have no idea if this is possible. What I want to do is to trigger a url everytime something new happens on a users timeline (?). Is this possible, and if so, how do I do it?

Upvotes: 0

Views: 289

Answers (1)

Dave
Dave

Reputation: 11889

Yes, but it takes a bit of work. You need to use the twitter streaming API, specifically the follow option.

From twitter:

Example: Create a file called ‘following’ that contains, exactly and excluding the quotation marks: “follow=12,13,15,16,20,87” then execute:

curl -d @following https://stream.twitter.com/1/statuses/filter.json -uAnyTwitterUser:Password.

Basically you pass a list of user ids you want to follow, open a long-lived connection, and twitter sends back to you anything that the user posts publicly. You can monitor this connection and do things when a user posts something.

You have another option, called a User Stream , which gets you way more information about when a user does anything, but it requires the user's approval, and a much more complex authentication process via oAuth. So I would only use that if you need it.

How you're going to be keeping a persistant connection open to twitter is something very much dependent on your programming language and software. In Python, I really like tweepy, but even for python there are several different libraries, or you can just use curl or pycurl and do it yourself like in the example above.

Upvotes: 1

Related Questions