Created
October 9, 2012 19:51
-
-
Save idooo/3861015 to your computer and use it in GitHub Desktop.
tweenk oauth
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# в твинке используюся библиотека tweepy, но документации к ней не особо дофига | |
# примерно так это работает у нас | |
# твои ключи приложения с dev.twitter.com | |
consumer_key = '' | |
consumer_secret = '' | |
.... | |
# редиректишь пользователя на страницу авторизации приложения | |
auth = tweepy.OAuthHandler(consumer_key, consumer_secret) | |
url = auth.get_authorization_url(True) | |
return ....redirect(url) | |
.... | |
# пользователь авторизовывает твое приложение и твиттре редиректит его по адресу который ты написал | |
# в Callback URL в настройках своего приложения на dev.twitter.com | |
# обрабатываешь параметры которые пришли: | |
auth = tweepy.OAuthHandler(consumer_key, consumer_secret) | |
auth.set_request_token(param['oauth_token'], param['oauth_verifier']) | |
auth.get_access_token(param['oauth_verifier']) | |
api = tweepy.API(auth) | |
# получаешь инфу | |
user = api.me() | |
# работаешь с инфой, например: | |
fields = { | |
'id': user.id, | |
'login_name': user.screen_name, | |
'avatar': user.profile_image_url, | |
'access_key': auth.access_token.key, | |
'access_secret': auth.access_token.secret, | |
'utc': user.utc_offset | |
} | |
# или: | |
player = self.isPlayerAlreadyRegistered(user.id) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment