Twython。验证问题[Twitter API返回401]

时间:2013-10-21 15:21:12

标签: python-2.7 twitter oauth twython

所以这是我的代码到目前为止,我不确定我做错了什么。 OAUTH_TOKEN和OAUTH_TOKEN_SECERT打印出来就好了,它只是在显示时间轴时似乎无法正常工作。

def login():

    APP_KEY = 'xxxxxx'
    APP_SECRET = 'xxxxxxx'

    log = Twython(APP_KEY, APP_SECRET)
    auth = log.get_authentication_tokens()
    webbrowser.open(auth['auth_url'], new=2, autoraise=True)
    print 'If your web browser did not open go to this url: ' + auth['auth_url']
    oauthverify = int(input('Please enter the PIN displayed: '))
    print auth['oauth_token']
    print auth['oauth_token_secret']
    twitter = Twython(APP_KEY, APP_SECRET, auth['oauth_token'], auth['oauth_token_secret'])
    final = twitter.get_authorized_tokens(oauthverify)

    OAUTH_TOKEN = final['oauth_token']
    OAUTH_TOKEN_SECERT = final['oauth_token_secret']

    print OAUTH_TOKEN
    print OAUTH_TOKEN_SECERT

    print twitter.get_home_timeline()

0 个答案:

没有答案