【问题标题】:Node.js Twitter Bot returning Error: Bad Twitter streaming request: 410Node.js Twitter Bot 返回错误:错误的 Twitter 流请求:410
【发布时间】:2019-01-25 02:56:43
【问题描述】:

我运行了这个机器人,它运行了大约 8 个小时,但现在我一运行它就会出现以下问题:

events.js:183
  throw er; // Unhandled 'error' event
  ^Error: Bad Twitter streaming request: 410
at Object.exports.makeTwitError (C:\Users\arghya\Documents\Node-JS\Gracias\node_modules\twit\lib\helpers.js:74:13)
at Request.<anonymous> (C:\Users\arghya\Documents\Node-JS\Gracias\node_modules\twit\lib\streaming-api-connection.js:96:29)
at emitOne (events.js:121:20)
at Request.emit (events.js:211:7)
at IncomingMessage.<anonymous> (C:\Users\arghya\Documents\Node-JS\Gracias\node_modules\request\request.js:1083:12)
at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)

您可以参考代码here

编辑:几个小时后,相同的代码开始工作。我猜这是 API 的超时问题。

【问题讨论】:

    标签: node.js twitter npm bots


    【解决方案1】:

    您在代码中通过 var stream = twitter.stream('user'); 使用的 API 指的是已弃用的用户流端点。

    这将在 8 月 23 日完全删除,但在该日期之前,端点会定期关闭,以提醒开发人员他们需要 migrate 以使用其他方法,例如 Account Activity API。您可以阅读有关此停机时间安排的更多信息here。这就是您看到临时 410 错误的原因。这周会越来越频繁。

    【讨论】:

    • 那么现在要使用流式 API,我们可以使用 twit 或 twitter npm 包还是需要使用 express 创建完整的 webAPI?
    • 那么我如何使用 Twit 接收直接消息?
    • twit 模块目前不支持可以实时传递直接消息的帐户活动 API,您需要使用替代库。
    猜你喜欢
    • 2020-12-06
    • 2021-05-28
    • 2019-02-24
    • 2017-11-03
    • 1970-01-01
    • 2013-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多