【问题标题】:Posting twitter thread using Twitter4j使用 Twitter4j 发布 Twitter 线程
【发布时间】:2019-06-05 20:32:19
【问题描述】:

我试图弄清楚如何使用 Twitter4J 使用 Twitter4J 发布推文线程。我猜它会以某种方式使用StatusUpdate 类,但文档有点稀疏。有什么指点吗?

【问题讨论】:

    标签: java twitter twitter4j


    【解决方案1】:

    您应该将 inReplyToStatusId 设置为在第一条推文之后发布的每条推文的最新发布状态 ID。 inReplyToStatusId 的默认值为 -1。

    例子:

    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++;
    }
    

    【讨论】:

    • 只是一个快速的错字更正:lastPostedStatusId 应该是 inReplyToStatusId
    猜你喜欢
    • 2013-05-04
    • 2014-10-22
    • 2012-09-20
    • 2014-02-18
    • 1970-01-01
    • 2012-03-28
    • 2021-04-11
    • 1970-01-01
    • 2014-09-02
    相关资源
    最近更新 更多