如何使用twitter api v 1.1查找用户的总推文?

时间:2014-05-02 11:46:54

标签: php api twitter

您好我想查找用户的总推文数,例如here您可以看到推文计数为14 ..我有api密钥和所有,我只想要api电话。

我编码了这个

        $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);

我得到了follwoers点数和following计数现在我想要总计tweet计算任何想法如何得到这个?

1 个答案:

答案 0 :(得分:6)

看看这个:

$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);