Question

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

Was it helpful?

Solution 2

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.

OTHER TIPS

I can only think that maybe twitter isn't the Twitter library you think it is:

Try to see if you get something similar to this:

>>> 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))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top