【问题标题】:python-Twitter-apipython-Twitter-api
【发布时间】:2023-04-02 00:39:01
【问题描述】:
import twitter

client = twitter.Api()

client = twitter.Api(username='uname', password='password')

update = client.PostUpdate('Tweetin from python!')

这是我的代码。 当我执行这个程序时,我得到了这个错误

TypeError: __init__() got an unexpected keyword argument 'username'

有人可以帮我吗?

【问题讨论】:

  • 您使用的 twitter 模块没有 API 构造函数的 usernamepassword 参数。你读过文档吗?

标签: python api twitter


【解决方案1】:

【讨论】:

    【解决方案2】:

    根据文档,您必须使用 OAuth,并在 API 构造函数中指定密钥和访问令牌: http://code.google.com/p/python-twitter/

    >>> api = twitter.Api(consumer_key='consumer_key',
    consumer_secret='consumer_secret', access_token_key='access_token', access_token_secret='access_token_secret')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-13
      • 1970-01-01
      • 2012-02-10
      • 1970-01-01
      • 1970-01-01
      • 2011-04-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多