开发者

Multiple twitter users' feed on one site without reaching the rate limit

开发者 https://www.devze.com 2023-03-01 05:19 出处:网络
I have a large number of twitter users I wish to sydicate onto a website using PHP and caching the tweets in MySQL. However I seem to be stumped by the rate-limit problem when ever I access the API. E

I have a large number of twitter users I wish to sydicate onto a website using PHP and caching the tweets in MySQL. However I seem to be stumped by the rate-limit problem when ever I access the API. Every request I make to every user seems to count as a request, which stands to reason.

I notice other si开发者_JS百科tes* doing this exact thing successfully. How are they getting around this, are they simply whitelisted, or is there a technique I'm missing?

*http://www.twackle.com/NFL/Aaron-Rodgers_1/tweets


The streaming API is what you are looking for, and more specifically, the filter method. Filter, at its least-privileged level, will allow you to follow 5,000 users in realtime, without them having to authorize your app, and you can track up to 400 keywords using this method as well.

Now, if you want historical tweets as well, you will have to pull those from the REST API (the streaming API's count parameter doesn't really help here), but since you can only retrieve the last 3200 tweets for a user via the REST API, you can pretty much backfill all available tweet history with 16 calls to statuses/user_timeline by passing in a count parameter value of 200 and paging accordingly.

http://api.twitter.com/1/statuses/user_timeline.json?screen_name=barackobama&count=200&page=2 http://api.twitter.com/1/statuses/user_timeline.json?screen_name=barackobama&count=200&page=3 http://api.twitter.com/1/statuses/user_timeline.json?screen_name=barackobama&count=200&page=4

With your 350 calls per hour per single Twitter account, you could backfill approximately 22 full user timelines per hour.

On the implementation side, you'd probably be interested in Phirehose, a streaming API client interface for PHP.


try to auth first, before get the tweets. that should increase the rate limit


A simple method of combining multiple user_timelines is to create a Twitter list and use GET /:user/lists/:id/status. That single API request will return the most recent tweets from all users on the list.

0

精彩评论

暂无评论...
验证码 换一张
取 消