Twitter is one of the most used social networking websites on the internet. Twitter API allows you to retrieve info for specific user. All you need to do is to enter the handler of the user. You can easily retrieve a specific Twitter user’s followers count with a small snippet:
function twitter_user_info($screen_name){ $data = file_get_contents("https://cdn.api.twitter.com/1/users/lookup.json?screen_name=" . $screen_name); $data = json_decode($data, true); return $data[0]; } $twitter = twitter_user_info("HardeepAsrani"); echo "Followers count: " . $twitter['followers_count'];
Just replace HardeepAsrani in the above code with your Twitter handler to retrieve your followers. Just like this example, you can also retrieve possibly every public Twitter user info with this API.
You can retrieve every Twitter info with following snippet:
function twitter_user_info($screen_name){ $data = file_get_contents("https://cdn.api.twitter.com/1/users/lookup.json?screen_name=" . $screen_name); $data = json_decode($data, true); return $data[0]; } $twitter = twitter_user_info("HardeepAsrani"); print_r($twitter);
The above code will give you following output:
Array ( [id] => 141906925 [id_str] => 141906925 [name] => Hardeep Asrani [screen_name] => HardeepAsrani [location] => Kanpur,India [url] => https://www.trickspanda.com [description] => CM Punk T-Shirt Guy... #WWE #ProWrestling #MMA #Blogger #WordPress [protected] => [followers_count] => 1816 [friends_count] => 352 [listed_count] => 2 [created_at] => Sun May 09 11:05:32 +0000 2010 [favourites_count] => 50 [utc_offset] => 19800 [time_zone] => New Delhi [geo_enabled] => 1 [verified] => [statuses_count] => 41723 [lang] => en )
Isn’t easy. You don’t need to enter any authentication keys or nothing. You just need to inter the Twitter handler of the user. You can retrieve info for more than user by separate them by comma:
function twitter_user_info($screen_name){ $data = file_get_contents("https://cdn.api.twitter.com/1/users/lookup.json?screen_name=" . $screen_name); $data = json_decode($data, true); return $data[0]; } $twitter = twitter_user_info("HardeepAsrani,TricksPanda"); print_r($twitter);
That’s it. Now, you can retrieve every public info from your Twitter profile without anything, but a small snippet.
Twitter API 1.0 is Deprecated and API 1.1 is now available. You should use it.
Thanks for notifying. I’ll look for it :)
any way to get all followers name ?
Check this: https://dev.twitter.com/rest/reference/get/followers/list
And this out: http://stackoverflow.com/questions/17417379/how-to-get-full-list-of-twitter-followers-using-new-api-1-1
Thanks….