3 Easy Steps to Creating Awesome Twitter lists via the Twitter API

Creating lists in twitter is a fantastic way to curate tweets for your perusal based on the interests you have. It would be just as simple to follow any and all accounts you enjoy based on all of your interests but the problem here is, you probably have a lot of interests. Once you follow all the accounts related to all of your interests, you can no longer manage your own timeline. Oddly, as the number of accounts you follow grows, the engagement value of your own timeline declines. This is where lists come in. We can create lists based on our interests to follow many accounts, while still keeping our timeline at a nice level. Let’s tackle creating lists with the Twitter API right now!

Why Use Twitter the API?

As you can see, there is a lot of discussion about programming here at Vegibit. So the first answer to this question is simple. It’s Fun! Beyond that, creating lists can be a time consuming activity. For this example, we’ll create a list, find 20 of the top twitter accounts for our chosen interest, then add all of those users to our new list with one simple PHP script!

1. Create a Twitter App

In order to complete this exercise, you need a twitter app from https://dev.twitter.com/. It’s very easy to set up and once complete you can use your app key, your app secret, your access token, and your access token secret in the script.

2. Create the PHP script

For this example we create a Codeigniter Controller called Listr with a create method to complete our task.

3. Run the PHP script

We run the script by loading up the url in our browser. For a localhost installation such as the one used for this example, it would be something like http://localhost/debug/listr/create/marketing. Let’s test it out now and see what happens!

twitter lists
And… Bazinga!! Here we can see simply by loading our small program in our browser, a fresh new list called ‘marketing’ is created with 20 awesome twitter accounts added, in about 3 seconds!

Thank you for reading 3 Easy Steps to Creating Awesome Twitter lists via the Twitter API – If you found this post helpful, Please do share using the buttons below!