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

标签 php api twitter

嗨,我想查找用户的推文总数,例如 here你可以看到推文计数是 14..我有 api key 等等,我只想要 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);

我得到了folwoers计数和following计数,现在我想要总tweet计数知道如何得到这个吗?

最佳答案

看看这个:

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

关于php - 如何使用 twitter api v 1.1 查找用户的推文总数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23427416/

相关文章:

php - 当从表中更新列行时,然后在该列的所有行中提取

ruby - Grape 中的多个路由参数

jquery - 为什么 jQuery.camelCase() 函数没有记录?

api - Google Oauth2 userinfo API 不返回用户名数据

android - 使用 Twitter4j 播放视频

使用 Twitter 屏幕名称获取任何用户的 Twitter 关注者的 Java 代码

php - 提取数组 2 的键和值,其中值数组 1 = 键数组 2

php - 如何使用 PHP 在 MySQL 表中插入数组?

php - MySQL "no database selected"

java - 根据单词出现频率查找推特中的热门话题