简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM