我正在像这样使用 TwitterFactory:
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey("xxxxxxxxxxxxxx")
.setOAuthConsumerSecret("xxxxxxxxxxxxx")
.setOAuthAccessToken(xxxxxxxxxxxxx )
.setOAuthAccessTokenSecret(xxxxxxxxxxxxx);
TwitterFactory tf = new TwitterFactory(cb.build());
twitter = tf.getInstance();
long cursor = -1;
IDs ids = twitter.getFollowersIDs(cursor);
问题是我不想要 ID,但我需要获取关注者的用户名,但我不知道怎么做?您对我应该如何获取用户名有任何想法吗?
代码更新:
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey("xxxxxxxxxxxxxx")
.setOAuthConsumerSecret("xxxxxxxxxxxxx")
.setOAuthAccessToken(xxxxxxxxxxxxx )
.setOAuthAccessTokenSecret(xxxxxxxxxxxxx);
TwitterFactory tf = new TwitterFactory(cb.build());
twitter = tf.getInstance();
long cursor = -1;
IDs ids = twitter.getFollowersIDs(cursor);
long[] id = ids.getIDs();
ResponseList<User> users = twitter.lookupUsers(id);
for (User user : users) {
usernames.add(user.getScreenName());
}
}