【问题标题】:How to Reply to a Tweet from Stream Using Node Module Twit如何使用节点模块 Twit 从流中回复推文
【发布时间】:2020-10-04 05:03:47
【问题描述】:

我尝试回答从信息流中获得的推文。我已阅读 this 文章,但不知何故它对我不起作用。该推文已发布,但不是作为回复,并且在我返回的 JSON 中是 in_reply_to_status_id: null

这是我的代码:

stream.on('tweet', function (tweet) {
  if ((tweet.text.includes("Oh") || tweet.text.includes("oh") || tweet.text.includes("O") || tweet.text.includes("o")) && (tweet.text.includes("gott") || tweet.text.includes("Gott"))){
    // console.log(tweet)

    const tweetId = tweet.id;

    T.post('statuses/update', { in_reply_to_status_id: tweetId, status: 'Oh Gott' }, (err, data, response) => {
      console.log(data)
    })
  }
})

【问题讨论】:

    标签: node.js api twitter


    【解决方案1】:

    由于这是 JavaScript,它可能会破坏 Tweet ID 值(请参阅Twitter IDs here)。您可能需要使用

    const tweetId = tweet.id_str

    这将防止长整数被 JavaScript 更改。

    【讨论】:

      猜你喜欢
      • 2017-11-23
      • 2021-05-13
      • 2014-04-30
      • 1970-01-01
      • 2016-01-09
      • 1970-01-01
      • 2018-02-16
      • 2020-10-11
      • 1970-01-01
      相关资源
      最近更新 更多