【问题标题】:Changes to Twython in effect of Twitter REST API version changeTwitter REST API 版本更改对 Twython 的更改
【发布时间】:2026-02-15 10:00:02
【问题描述】:

我一直在尝试使用 Twython 从 Twitter API 中提取数据。最近,Twitter API 将版本从 v1 更改为 v1.1。我不明白在使用 Twython 时需要进行的更改(如果有的话)。我使用 Twython 2.5.5。我以前使用的命令突然不再工作了。请帮助我完成这个过渡,以便我可以更快地完成工作。提前致谢。

这是我正在使用的代码 sn-p:

twitter = twython.Twython(oauth_token = oauth_token, oauth_token_secret = oauth_secret, app_key = oauth_consumer_key, app_secret = oauth_consumer_secret)
twitter.getRetweets(id="123")

这是显示的错误:

TwythonError: 'Unauthorized: Authentication credentials were missing or incorrect. -- An error occurred processing your request.'

【问题讨论】:

  • 欢迎来到 Stack Overflow。请查看提问指南:*.com/questions/how-to-ask
  • 我添加了一个代码 sn-p 以突出显示我面临的问题的细节。

标签: python-2.7 twitter twython


【解决方案1】:

我迟到了这个问题,但如果您(或其他任何人)对此有进一步的问题,我相信这是由于 Twitter(在某种程度上)最近引入的 OAuth 验证器更改。 Twython 在较新的版本中支持此功能,we have examples

from twython import Twython

t = Twython(app_key, app_secret, oauth_token, oauth_token_secret)
auth_tokens = t.get_authorized_tokens(oauth_verifier)
print auth_tokens

【讨论】: