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:esttweet.py", line 20, in <module>
final_step = twitter.get_authorized_tokens(oauth_verifier)
File "C:Python27libsite-packageswythonapi.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
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…