Search code examples
pythonjsontwitteroauthpython-twitter

Python-twitter - unexpected keyword argument 'access_token_key'


#!/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()

This code doesn't work, it's taken directly from the readme and every example i find. I found something about "get_access_token.py" and theres no reference to it!?

user@host:~# updatedb
user@host:~# locate get_access_token
user@host:~#

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

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


Solution

  • Wrong version of the API. Was using an older version mainly (only?) supporting username/password authentication.

    Was using "0.6-devel" of twitter.py
    Updated to 0.8.X and it works, better..

    EDIT:

    The API is also outdated, it doesn't support Streaming API via Twitter meaning that you'll only get important posts, i needed to get all posts on a hashtag search.

    I reccomend:
    SixOhSix twitter API: https://github.com/sixohsix/twitter Easy to use, worked like a charm and gets you the result you need.