我正在尝试使用来自 Django 支持的站点的 Twython 发布推文。但是,“twitter.updateStatus(status=tweet_text)”行会导致以下错误:
TwythonError: u'Unauthorized: Authentication credentials were missing or incorrect. -- Invalid / expired Token'
我确实有请求版本 0.13.9,所以这应该不是问题:
>>>import pkg_resources
>>>pkg_resources.get_distribution("requests").version
'0.13.9'
>>>pkg_resources.get_distribution("twython").version
'2.3.4'
知道如何解决这个问题吗?提前致谢!
这是python方法本身:
def tweet_link(request, tweet_text):
try:
c = RequestContext(request)
twitter = Twython(
twitter_token = TWITTER_KEY,
twitter_secret = TWITTER_SECRET,
oauth_token = request.session['request_token']['oauth_token'],
oauth_token_secret = request.session['request_token']['oauth_token_secret']
)
twitter.updateStatus(status=tweet_text)
except Exception, e:
print traceback.print_exc()
return HttpResponse('')