Testing the twitter app on local server in django with twython

与世无争的帅哥 提交于 2019-12-04 18:11:57
def social_home(request):
    oauth_token_secret = request.session['twitter_auth']['oauth_token_secret']
    oauth_token = request.session['twitter_auth']['oauth_token']
    twitter = Twython(settings.TWITTER_KEY, settings.TWITTER_SECRET, oauth_token, oauth_token_secret)
    authorized_tokens = twitter.get_authorized_tokens(request.GET['oauth_verifier'])

    twitter = Twython(settings.TWITTER_KEY, settings.TWITTER_SECRET, authorized_tokens['oauth_token'], authorized_tokens['oauth_token_secret'])
    user_tweets = twitter.get_home_timeline()
    return render(request, "social_summary.html", {"user_tweets":user_tweets})

That should work! :) Good luck!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!