Reputation: 509
Under python2.7 and already installed the requirements.txt from the twitter-python Building section
It's the first time I'm jumping in, and following the basics steps to ensure is everything okay as described here in this link twitter-python Documentation section, I'm getting an error.
Here the typen at command line Python shell:
>>> api = twitter.Api(consumer_key='consumer_key',
consumer_secret='consumer_secret',
access_token_key='access_token',
access_token_secret='access_token_secret')
The error:
>>> print api.VerifyCredentials()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ubuntu/.virtualenvs/twitter/local/lib/python2.7/site- packages/python_twitter-1.2-py2.7.egg/twitter.py", line 5209, in VerifyCredentials
data = self._ParseAndCheckTwitter(json.content)
File "/home/ubuntu/.virtualenvs/twitter/local/lib/python2.7/site-packages/python_twitter-1.2-py2.7.egg/twitter.py", line 5462, in _ParseAndCheckTwitter
self._CheckForTwitterError(data)
File "/home/ubuntu/.virtualenvs/twitter/local/lib/python2.7/site-packages/python_twitter-1.2-py2.7.egg/twitter.py", line 5487, in _CheckForTwitterError
raise TwitterError(data['errors'])
twitter.TwitterError: [{u'message': u'Invalid or expired token', u'code': 89}]
What could I be missing here?
Upvotes: 0
Views: 757
Reputation: 102842
You need to replace 'consumer_key'
, 'consumer_secret'
, 'access_token'
, and 'access_token_secret'
with their actual values. You can either put those values directly in the twitter.Api()
call, or assign their values to variables:
>>> # all these values are just random, you'll need to use your own values
>>> c_key = '123456'
>>> c_secret = 'a88d098cd76'
>>> token = '98765'
>>> token_secret = 'ad98c63e87f00'
>>> api = twitter.Api(consumer_key=c_key,
consumer_secret=c_secret,
access_token_key=token,
access_token_secret=token_secret)
Upvotes: 3
Reputation: 1961
I'm not sure but it looks like you need a valid consumer_key, consumer_secret, access_token_key and access_token_secret. This will involve you setting up your own app on twitter.com and using the consumer keys/secrets and test access_token keys/secrets to get started.
Upvotes: 1