npm 发布到Twitter失败:错误:您当前可以访问Twitter API v2端点的子集和有限的v1.1端点(例如媒体发布,oauth).

jjhzyzn0  于 9个月前  发布在  其他
关注(0)|答案(1)|浏览(202)

我有一个运行NPM Twit [https://www.npmjs.com/package/twit]的JavaScript应用程序可以发布到Twitter。我的机器人最近停止工作,没有任何解释或警告。Twitter似乎要求我从旧的免费层升级到新的免费层,这要求我删除我的Twitter Dev帐户中的所有内容,然后重新创建我的项目和应用程序。我这样做了,我确保我选择了读写权限。
我的授权有效。当我运行twitClient.get('account/verify_credentials', {…})时,我会收到所有帐户详细信息。
但是有什么东西阻止了我的代码发tweeting。当我运行twitClient.post('statuses/update', {…}, function (error, success) {})时,我收到:

Post to Twitter failure: Error: You currently have access to a subset of Twitter API v2 endpoints and limited v1.1 endpoints (e.g. media post, oauth) only. If you need access to this endpoint, you may need a different access level. You can learn more here: https://developer.twitter.com/en/portal/product
    at exports.makeTwitError (/Users/…/node_modules/twit/lib/helpers.js:74:13)
    at onRequestComplete (/Users/…/node_modules/twit/lib/twitter.js:344:25)
    at Request.<anonymous> (/Users/…/node_modules/twit/lib/twitter.js:364:7)
    at Request.emit (node:events:523:35)
    at Gunzip.<anonymous> (/Users/…/node_modules/request/request.js:1076:12)
    at Object.onceWrapper (node:events:625:28)
    at Gunzip.emit (node:events:511:28)
    at endReadableNT (node:internal/streams/readable:1367:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: 453,
  allErrors: [
    {
      message: 'You currently have access to a subset of Twitter API v2 endpoints and limited v1.1 endpoints (e.g. media post, oauth) only. If you need access to this endpoint, you may need a different access level. You can learn more here: https://developer.twitter.com/en/portal/product',
      code: 453
    }
  ],
  twitterReply: { errors: [ [Object] ] },
  statusCode: 403
}

字符串
我试过用Twitter API V2 [https://www.npmjs.com/package/twitter-api-v2]等更新的东西来替换Twit,但是tweeting的语法完全不同。
我试图寻找答案,但我只找到了Python代码。

r6vfmomb

r6vfmomb1#

POST /2/tweets目前是免费的计划,所以你应该能够发布tweets没有升级v2。检查这个文档,https://developer.twitter.com/en/docs/twitter-api/tweets/manage-tweets/migrate,因为你已经找到了一些代码,所以我不包括它。
从文档中,为了让你更清楚,
“v2管理推文端点将取代标准v1.1 POST statuses/update和POST statuses/destroy/:id端点。如果您的代码、应用程序或工具使用v1.1版本的管理推文端点,并且正在考虑迁移到较新的Twitter API v2端点,那么这组指南适合您。“

相关问题