PHP Twitter Followers Count script (v1.1 API)

Php Twitter Followers Count

The following PHP Twitter Followers Count script is using the new v1.1 Twitter API.



Recently, Twitter have changed their API and v1.0 is obselete. The new API requires OAuth. I’ll explain how to get your twitter followers count using PHP.


Create Application

First, you’ll need to get yourself a twitter dev account, if you haven’t done so yet.

Go here and register your app free.



Download the TwitterAPIExchange library files created by J7mbo into your application.

you can git clone

I recommend the git method as you can git pull later to recieve updated.


Get Followers Count

Insert your OATH and Consumer Access-Token & Access-Token secret the the following code. Also, change the $getfield screen name to yours.

Now combine everything to make it work


/** Set access tokens here - see: **/
$settings = array(
'oauth_access_token' => "YOUR_OAUTH_ACCESS_TOKEN",
'oauth_access_token_secret' => "YOUR_OAUTH_ACCESS_TOKEN_SECRET",
'consumer_key' => "YOUR_CONSUMER_KEY",
'consumer_secret' => "YOUR_CONSUMER_SECRET"

$ta_url = '';
$getfield = '?screen_name=replace_me;
$requestMethod = '
$twitter = new TwitterAPIExchange($settings);
->buildOauth($ta_url, $requestMethod)
$data = json_decode($follow_count, true);
echo $followers_count;



I’ve placed the entire twitter-api-php folder inside my project. you can extract the files also, but make sure to require_once() from the correct path.


if you’ve placed it inside the folder, or

require_once(‘TwitterAPIExchange.php’); if you extracted the files to the same folder as your script.


More information

This article was based on the work of Jimbo and Meenakshi Sundaram R

5 thoughts on “PHP Twitter Followers Count script (v1.1 API)

  1. Joaquin

    Can you help me? I can not run this code and got my keys and twitter the replacement does not work me. I do not print anything on the page! urges me please


Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.