Get a user's Followers Count using API v1.1


#1

I want to get the followers count of a user. I want to use this : “https://dev.twitter.com/docs/api/1.1/get/users/show”.

When I call a url like “https://api.twitter.com/1.1/users/show.json?screen_name=google” , it gives “Bad Authentication”.

I created an app & got my token codes but don’t know how to use them. Can you please help.

Basically, I want to get a user’s follower count using JavaScript.


#2

It’s unfortunately not really possible to use API v1.1 in pure Javascript environments without exposing your consumer keys. OAuth 1.0A and our app-only auth model are best suited for server-to-server programming. Have you taken a look at [node:13439]?


#3

Okay. So, can we do the same using php? If yes, how to do it?


#4

Here’s one example for getting twitter user data. The amount of results if limited though.

require('twitteroauth/twitteroauth.php');

function getTwitterData($username){
$consumer_key = “xxxxxxxxxxxxxxxxxxx”;
$consumer_secret = “xxxxxxxxxxxxxxxxxxx”;

$oauth_token = "xxxxxxxxxxxxxxxxxxx";
$oauth_token_secret = "xxxxxxxxxxxxxxxxxxx";
 
$connection = new TwitterOAuth($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
$user = $connection->get('https://api.twitter.com/1.1/users/show.json?screen_name='.$username);

return $user;

}


#5

Thank you @fhollste


#6