I'm trying to make python send a tweet for me using Twython but for some reason everything I'm trying isn't working.
I've followed the Twython README but still unable to acheive what I want.
Below is my latest attempted code:
from twython import Twython, TwythonError
APP_KEY = "KEYHERE"
APP_SECRET = "SECRETHERE"
twitter = Twython(APP_KEY, APP_SECRET)
auth = twitter.get_authentication_tokens()
OAUTH_TOKEN = auth['oauth_token']
OAUTH_TOKEN_SECRET = auth['oauth_token_secret']
twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
try:
twitter.update_status(status='See how easy this was?')
except TwythonError as e:
print e
On running the above code I get the following traceback error:
Twitter API returned a 401 (Unauthorized), Invalid or expired token
Does anyone know what I'm doing wrong and more importantly how do I fix this?
I dont have enough points for a bounty, but I would really appreciate the help!
Thanks in advance
edit
Traceback (most recent call last):
File "C:\testtweet.py", line 20, in <module>
final_step = twitter.get_authorized_tokens(oauth_verifier)
File "C:\Python27\lib\site-packages\twython\api.py", line 313, in get_authorized_tokens
raise TwythonError('Unable to decode authorized tokens.')
TwythonError: Unable to decode authorized tokens.
The above is the traceback recieved from the code supplied by @justhalf
Thanks SMNALLY
Twitter API returned a 401 (Unauthorized), Invalid or expired token
is it needs'oauth_verifier'
afterget_authentication_tokens()
more on it here also this might be helpful – Leylaoauth_verifier
– Leyla