简体   繁体   中英

Twitter API - Getting the retweet count of an account

I am looking to pull the total number of retweets a particular user has ever received. Is that possible?

Right now, I am able to pull the total tweet count, the number of followers and the number of friends.

The code I am working with is:

$username = "username";
$url = "https://api.twitter.com/1.1/users/show.json";
$requestMethod = "GET";
$getfield = "?screen_name=".$username."&include_entities=true";
$twitter = new TwitterAPIExchange($settings);
$string = json_decode($twitter->setGetfield($getfield)
    ->buildOauth($url, $requestMethod)
    ->performRequest(),$assoc = TRUE);

The total number of retweets is not a property associated to the Users . Each individual Tweet has the number of retweets it received in the field retweet_count.

You will need to get all the tweets of a user and add up the retweets to get the total retweets a user received. The problem you will find is that you are limited on the number of tweets you can get of a user to the last 3200 tweets https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-user_timeline.html .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM