【问题标题】:Python-twitter - unexpected keyword argument 'access_token_key'Python-twitter - 意外的关键字参数“access_token_key”
【发布时间】:2012-11-10 06:45:27
【问题描述】:
#!/usr/bin/python
# -*- coding: iso-8859-15 -*-
import twitter

class twitt():
    def __init__(self):
        consumer_key = '...'
        consumer_secret = '...'
        access_key = '...'
        access_secret = '...'

        encoding = 'iso-8859-15'

        self.api = twitter.Api(consumer_key=consumer_key, consumer_secret=consumer_secret, access_token_key=access_key, access_token_secret=access_secret, input_encoding=encoding)

    def run(self):
        statuses = self.api.GetPublicTimeline()
        print statuses

h = twitt()
h.run()

此代码不起作用,它直接取自自述文件和我找到的每个示例。 我发现了一些关于“get_access_token.py”的东西,但没有提到它!?

user@host:~# 更新b
user@host:~# 定位 get_access_token
用户@主机:~#

错误: TypeError: __init__() got an unexpected keyword argument 'access_token_key'

参考:
- http://code.google.com/p/python-twitter/issues/detail?id=215
- https://github.com/bear/python-twitter/tree/master/examples

【问题讨论】:

    标签: python json twitter oauth python-twitter


    【解决方案1】:

    我只能认为twitter 可能不是你认为的 Twitter 库:

    尝试看看你是否得到类似的东西:

    >>> import twitter
    >>> twitter.__file__
    '/usr/local/lib/python2.7/dist-packages/python_twitter-0.8.2-py2.7.egg/twitter.pyc'
    
    >>> import inspect
    >>> inspect.getargspec(twitter.Api.__init__)
    ArgSpec(args=['self', 'consumer_key', 'consumer_secret', 'access_token_key', 'access_token_secret', 'input_encoding', 'request_headers', 'cache', 'shortner', 'base_url', 'use_gzip_compression', 'debugHTTP'], varargs=None, keywords=None, defaults=(None, None, None, None, None, None, <object object at 0x7f023505a220>, None, None, False, False))
    

    【讨论】:

    • 如果时间的话,那可能会为我节省一点时间。尽管如此,主要原因是我使用的是 apt-get install python-twitter 收到的旧版本的库:/
    【解决方案2】:

    API 版本错误。 主要(仅?)使用旧版本支持用户名/密码身份验证。

    正在使用 twitter.py 的“0.6-devel”
    更新到 0.8.X,效果更好..

    编辑:

    该 API 也已过时,它不支持通过 Twitter 的 Streaming API,这意味着您只会获得重要的帖子,我需要在主题标签搜索中获得所有帖子。

    我建议:
    SixOhSix 推特 API:https://github.com/sixohsix/twitter 易于使用,工作起来就像一个魅力,并为您提供所需的结果。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-07-06
      • 1970-01-01
      • 2014-12-03
      • 1970-01-01
      • 1970-01-01
      • 2015-10-11
      • 2013-10-29
      相关资源
      最近更新 更多