tags:

views:

155

answers:

3

Hi, I'm trying to create a widget on my blog that grabs about 20 twitter accounts and displays the last two posts from each account. At the moment I have a jquery based version that runs a for loop for each account. Naturally I bumped up against the 150 requests per hours maximum pretty fast. My question is two fold:

Is there a more efficient way to grab this info? Say opening a twitter account, follow all the users I need and then just reference the friends aspect of my account?

Is there a way to cache the JSON response so I don't bump into the limit? Or do I have to write the entire results to a file and reference that once the limit has been hit?

I should also mention the platform I'm working on is Wordpress/LAMP but I don't care what the technology end up being, I'm open to flash, etc to make this work.

Thanks all

+2  A: 

To guarantee showing two posts from each account, you'd probably need to pull each feed down separately. If one author wrote 100 tweets then no one else's tweets would be easily reached within a combined feed.

Your best bet is to get some PHP to download the tweets for you and cache them temporarily on the server, rather than using jquery and AJAX on the client side. A fairly simple Wordpress plugin would do it if you can do PHP. Alex King wrote a Twitter WordPress plugin which can pull down one account, perhaps you could modify it to subscribe to more.

David Carrington
+1  A: 

I took everyone's advice and grabbed a PHP twitter library (twitter.lib.php) and pointed it to a feed who's only purpose is to grab friend tweets. Works like a charm and I haven't hit any API limits yet.

Thanks for the help, problem solved.

rustbucket
A: 

Yeah, your suggestion seems like the most optimal way. Create an extra Twitter account and use the friends timeline to aggregate this data. Keep all the large-scale processing on Twitter's end.

Just be sure to cache your results server-side for about a minute or so.

MiffTheFox