Nithin Dev
Nithin Dev

Reputation: 421

How to find total tweets of a user using twitter api v 1.1?

Hi i want to find total number tweets of a user for example here you can see the tweet count is 14.. I have api keys and all, I just want the api call.

I coded up to this

        $twitteruser = "Username";
        $notweets = 5000;
        $consumerkey = "#########################";
        $consumersecret = "###############################";
        $accesstoken = "####################################";
        $accesstokensecret = "$$$$$$$$$$$$$$$$$$$$$$$$$$$";

        function getConnectionWithAccessToken($cons_key, $cons_secret, $oauth_token, $oauth_token_secret) {
          $connection = new TwitterOAuth($cons_key, $cons_secret, $oauth_token, $oauth_token_secret);
          return $connection;
        }

        $connection = getConnectionWithAccessToken($consumerkey, $consumersecret, $accesstoken, $accesstokensecret);

         //
        $following = $connection->get("https://api.twitter.com/1.1/friends/ids.json?cursor=-1&screen_name=".$twitteruser."&count=".$notweets);

        echo'<pre>'; echo count($following->ids);

        $followers = $connection->get("https://api.twitter.com/1.1/followers/ids.json?cursor=-1&screen_name=".$twitteruser."&count=".$notweets);

        echo'<pre>'; echo count($followers->ids);

I gets the follwoers count and following count now i want the total tweet count any idea how to get this?

Upvotes: 3

Views: 4849

Answers (1)

Tanatos
Tanatos

Reputation: 1917

Have a look at this :

$user = $connection->get("https://api.twitter.com/1.1/users/show.json?screen_name=".$twitteruser);
$following = intval($user->friends_count);
$followers = intval($user->followers_count);
$tweets = intval($user->statuses_count); 

Upvotes: 8

Related Questions