redouane59 / twittered

Twitter API client for Java developers
Apache License 2.0
235 stars 64 forks source link

How to post a tweet and then reply to it? #365

Closed LewBr closed 2 years ago

LewBr commented 2 years ago

Hello, i have the following question: How can I post a Tweet and reply to it? I'm trying to do it by getting the last tweet of the bot and trying to reply using that code:

TweetParameters tweetParameters = TweetParameters.builder()
                    .text("Hi")
                    .reply(Reply.builder().inReplyToTweetId(tweet.getId()).build())
                    .build();
            TWITTER_CLIENT.postTweet(tweetParameters);

Is that how I need to do it? But i don't know how to get the tweet variable correctly, please help me. Thanks :)

redouane59 commented 2 years ago

Hey, you have to get the tweetId from the postTweet method (it returns something!).

LewBr commented 2 years ago

Hello, thanks for the response, I have tried doing this:

TweetParameters tweetParameters = TweetParameters.builder()
                    .text("Hello this is a reply")
                    .reply(Reply.builder().inReplyToTweetId(TWITTER_CLIENT.postTweet("First tweet").getId()).build())
                    .build();
            TWITTER_CLIENT.postTweet(tweetParameters);

and still doesn't work :/

LewBr commented 2 years ago

Nevermind, it works actually, thanks.