Daily Archives: 2013-04-25

Export Twitter Friends Script

As part of my Tweetfave project, I wanted to get a better sense of the people I’m following and whether they use the Twitter “favorites” feature. By using the Twitter API, I’m able to first fetch my list of friends (i.e. people I am following), then get the detailed stats for each one. The result is a CSV file which can imported into Excel or other spreadsheet program:

Screenshot of Twitter friends in Excel

Twitter friend data loaded in Excel

This script is written in PHP and uses the Twitter OAuth PHP library. It uses the Twitter API methods friends/ids and users/lookup. Because the user lookup can handle up to 100 friends at a time, these APIs are quite efficient.

This script is available on GitHub (bcantoni/5457114), and embedded below. Follow the installation steps if you want to try it yourself.

Update: There is also a version of this script for exporting followers.