Alex
Alex

Reputation: 69

Display Twitter Follower Count with Twitter API 1.1

I have been using the twitter API 1.0 to get my number of followers very easily using:

$json_string = @file_get_contents('https://api.twitter.com/1/users/lookup.json?screen_name='.$twitterscreenName);
      if($json_string)
      {
         $data = json_decode($json_string, true);
         $data = number_format($data[0]['followers_count'], 0, ',', '.');};

Now twitter has updated their API to 1.1 this has stopped working.

Is there an easy way to get the follower count from a username (I have more than 100,000 followers currently is this a problem with the API?)

I ask this because I used one method which gave a result of 5000 which I really didn't understand.

Upvotes: 1

Views: 2836

Answers (1)

Once Upon a Dev
Once Upon a Dev

Reputation: 1108

You need to authenticate with Twitter using a registered account before you can make requests to the API. In addition to that, change

api.twitter.com/1/

to

api.twitter.com/1.1/

More information about the authentication can be found in the API documentation

Upvotes: 1

Related Questions