Twitter4J:从用户那里获取超过 1 条推文
我正在尝试获取关注者列表中每个用户的最近状态列表。我有以下内容可以让用户...
IDs list = twitter.getFriendsIDs(0);
for(long ID : list.getIDs()){
twitter4j.User TW_user = twitter.showUser(ID);
}
我能从中得到的只是 getStatus()
这是他们的最新状态。 getHomeTimeline()
也不够,因为我需要每个用户最近的推文列表。无论如何,我可以使用 Twitter4J 实现这一目标吗?
I'm trying to get a list of recent statuses from each user on a persons list of followers. I've got the following to get the users...
IDs list = twitter.getFriendsIDs(0);
for(long ID : list.getIDs()){
twitter4j.User TW_user = twitter.showUser(ID);
}
All I can get from this is getStatus()
which is their most recent status. getHomeTimeline()
is also insufficient as I need a list of recent tweets from each user. Is there anyway I can achieve this using Twitter4J?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我只是想自己找到这个答案。我使用 getUserTimeline 方法取得了相当大的成功。看起来您正在尝试查找朋友 ID 列表,因此下面的方法应该采用 long[] 并吐出所有用户状态。如果您想以这种方式查找用户,lookupUsers 还接受屏幕名称的 String[]。
I was just trying to find this answer myself. I had decent success using the getUserTimeline method. Looks like you're trying to look up a list of friend IDs, so this method below should take the long[] and spit out all the user statuses. lookupUsers also accepts a String[] of screen names if you want to look users up that way instead.
Alex 的答案很接近,但每个用户只能获得 100 条推文。以下内容将为您提供所有信息(或至少是 API 的最大限制):
Alex's answer is close, but will only get you 100 tweets per user. The following will get you all (or at least the API's max limit):