Data, Maps, Usability, and Performance

Grab Twitter List Tweets and Order by User

Last updated on July 24, 2012 in Development

Grab Twitter List Tweets PHP script

If you use Twitter than you might have heard about Twitter Lists, a curated group of Twitter users and their stream of tweets. It’s a pretty cool way of viewing tweets from a group of people that tweet about a particular subject. The lists can be private or public and there are many websites out there that help you dicover interesting tweets. Twitter Counter actually has a 100 most popular Twitter lists page that is ranked by followers count and refreshed daily.

One of my annoyances with viewing the stream of tweets, however, is that they are all organized by date and I would prefer to view Twitter tweets organized by user. This way I can disregard or hide tweets from a particular user that I don’t care about while not removing him or her from the list. I could even add some collapse/expand functionality and improve the user experience of that list page. I wish that Twitter had an “organize by user” view for any stream of tweets but for now I can show you how to use the twitter API and reorganize the list in a php script.

The following PHP script will retrieve tweets from a list similarly to the way I have previously grabbed tweets from a search query. The curl and autolink functions are pretty much the same while the getResults function provides more data (user name, user profile image, etc) in the result. By running a double foreach loop we can now reorganize all those tweets by user. Here is the code and demo:


Facebook Twitter Hacker News Reddit More...