问题
I'm trying to figure out how to use Twitter4J to post a tweet thread using Twitter4J. I'm guessing it would be somehow using the StatusUpdate
class, but the documentation is a bit sparse. Any pointers?
回答1:
You should set inReplyToStatusId as latest posted status id for every tweet coming after first tweet. Default value for inReplyToStatusId is -1.
Example:
long inReplyToStatusId = -1
int counter = 0
int threadLimit = 5
while (counter < threadLimit){
StatusUpdate statusUpdate = new StatusUpdate(Integer.toString(counter));
statusUpdate.setInReplyToStatusId(inReplyToStatusId);
Status updatedStatus = twitter.updateStatus(statusUpdate);
inReplyToStatusId = updatedStatus.getId();
counter++;
}
来源:https://stackoverflow.com/questions/54137712/posting-twitter-thread-using-twitter4j