Menu

#357 The isRetweetedByMe function doesn't work all times

open
nobody
None
2020-08-21
2020-08-21
Anonymous
No

Originally created by: raphaaell

I'm working on a code that retweet some tweets and I use the isRetweetedByMe() for check if the tweet is already retweet by me. Here is my code :

Query query = new Query("#Google");
        QueryResult result = twitter.search(query);
        for (Status status : result.getTweets()) {
            if(!status.isRetweet()){
                System.out.println("The tweet of : " + status.getUser().getName());
                System.out.println("was publish the : " + status.getCreatedAt());
                System.out.println("The url is : https://twitter.com/user/status/" + status.getId());
                System.out.println("Is retweeted by me : " + status.isRetweetedByMe());
                if(!status.isRetweetedByMe()){
                    System.out.println("Gonna retweet this tweet !");
                    twitter.retweetStatus(status.getId());
                    System.out.println("Successful retweet !");
                }else{
                    System.out.println("This tweet is already retweet by me !");
                }
            }
        }

And for the line System.out.println("Is retweeted by me : " + status.isRetweetedByMe()); the code tells me this tweet is not retweeted by me, so run the condition, and show me an error, this error :

403:The request is understood, but it has been refused. An accompanying error message will explain why. This code is used when requests are being denied due to update limits (https://support.twitter.com/articles/15364-about-twitter-limits-update-api-dm-and-following).
message - You have already retweeted this Tweet.
code - 327

Relevant discussions can be found on the Internet at:
    http://www.google.co.jp/search?q=2d3a38e0 or
    http://www.google.co.jp/search?q=1264cded
TwitterException{exceptionCode=[2d3a38e0-1264cded], statusCode=403, message=You have already retweeted this Tweet., code=327, retryAfter=-1, rateLimitStatus=null, version=4.0.1}
    at twitter4j.HttpClientImpl.handleRequest(HttpClientImpl.java:164)
    at twitter4j.HttpClientBase.request(HttpClientBase.java:53)
    at twitter4j.HttpClientBase.post(HttpClientBase.java:82)
    at twitter4j.TwitterImpl.post(TwitterImpl.java:1986)
    at twitter4j.TwitterImpl.retweetStatus(TwitterImpl.java:270)
    at fr.raphew.twitterbot.Retweet.function(Main.java:41)
    at fr.raphew.twitterbot.Retweet.run(Main.java:24)
    at java.util.TimerThread.mainLoop(Timer.java:555)
    at java.util.TimerThread.run(Timer.java:505)

But juste before, I go this :

The tweet of : ???????? FAM / MwS ?
was publish the : Fri Aug 21 15:12:15 CEST 2020
The url is : https://twitter.com/user/status/1296797263927238656
Is retweeted by me : false

And if I go to the tweet link, I have already retweeted the tweet.

Thanks.

Discussion


Log in to post a comment.