[英]How to remove retweet using twitter4j
Twitter4j 2.x had a method called getRetweetedByMe which could be used to delete a retweet. Twitter4j 2.x具有一个名为getRetweetedByMe的方法,该方法可用于删除转发。 However, I am using twitter4j 3.0 and that method has been removed.
但是,我使用的是twitter4j 3.0,该方法已删除。 I tried another solution but I am getting a error saying I can't removes someone else status.
我尝试了另一种解决方案,但出现错误,说我无法删除其他人的身份。 How can I accomplish removing retweets with this version of twitter4j.
如何使用此版本的twitter4j完成删除转发。
My Approach: 我的方法:
List<Status> retweets = twitter.getRetweets(statusId);
for (Status retweet : retweets)
if (retweet.getRetweetedStatus().getId() == statusId)
twitter.destroyStatus(retweet.getRetweetedStatus().getId());
I found out easier way (and probably a way which creators of the API wanted us to use). 我发现了更简单的方法(可能是API的创建者希望我们使用的方法)。 Part of my "unretweet" method:
我的“取消转发”方法的一部分:
long myRetweetId = status.getId(); if (status.getUser().getId() != getCurrentUser().getId()) { // not my retweet, but the original tweet myRetweetId = status.getCurrentUserRetweetId(); // <- } twitter.destroyStatus(myRetweetId);
Working with Twitter4J 4.0.1
. 使用
Twitter4J 4.0.1
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.