如何使用 Twitter4J 查找转发计数?
正如标题所示,我正在使用 Twitter4J API,但我似乎无法找到如何计算“Tweet”实例的转发次数。
As the title says, I'm using the Twitter4J API and I cannot seem to find how to count the retweets of a "Tweet" instance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
接口
StatusMethodsAsync
有一个getRetweets()
函数(如此处),但这仅显示给定推文的前 100 条首次转发。如果您知道转发次数少于 100 次,这应该可行。如果您在界面TwitterStream
中有更多内容,则所有转发的流(如所述这里),但这似乎并没有完全发挥作用,所以我不知道……但这可以让你走上正轨。
The interface
StatusMethodsAsync
has agetRetweets()
function (as described here) but that only shows the top 100 first retweets of a given tweet. If you know that there are less than 100 retweets this should work. If there are more you have in the interfaceTwitterStream
a stream of all retweets (as described here), but that doesn't seem fully functioning, so I wouldn't know then...But this could get you on the right track.
没有特定的计数函数,但 getRetweetedByIDs 将为您提供最多 100 个转发该推文的用户 ID 的数组。如果您想要的只是转发次数,那么这会更轻一些。如果您需要检索超过 100 个,
IDs
接口还支持光标,但我没有使用这些功能的经验。There is no specific count function, but
getRetweetedByIDs
will get you an array of up to 100 user ids who retweeted the tweet. This is a little more light-weight if all you want is the number of retweets. TheIDs
interface also has cursor support if you need to retrieve more than 100, but I have no experience with using those functions.