我的代码如下
import tweepy
CONSUMER_KEY = 'my_consumer_key'
CONSUMER_SECRET = 'my_consumer_secret'
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth_url = auth.get_authorization_url()
print 'Please authorize: ' + auth_url
verifier = raw_input('PIN: ').strip()
auth.get_access_token(verifier)
print "ACCESS_KEY = '%s'" % auth.access_token.key
print "ACCESS_SECRET = '%s'" % auth.access_token.secret
当我在终端中运行此脚本时,出现以下错误:
Traceback (most recent call last):
File "Twitter_OAuth.py", line 8, in <module>
auth_url = auth.get_authorization_url()
File "/usr/lib/python2.7/dist-packages/tweepy/auth.py", line 103, in get_authorization_url
raise TweepError(e)
tweepy.error.TweepError: HTTP Error 401: Unauthorized
我在网上搜索,我认为这与服务器时间有关。但我似乎无法解决它。
我正在使用 Ubuntu 12.10
帮助!