コード例 #1
0
ファイル: views.py プロジェクト: ahmontero/django-twitter
    def get(self, request, *args, **kwargs):
        # Exchange magic tokens for permanent ones and raise signal
        twitter = Twitter(twitter_token=settings.CONSUMER_KEY,
                          twitter_secret=settings.CONSUMER_SECRET,
                          oauth_token=self.request\
                            .session['request_token']['oauth_token'],
                          oauth_token_secret=self.request\
                            .session['request_token']['oauth_token_secret'])

        authorized_tokens = twitter.get_authorized_tokens()
        screen_name = authorized_tokens['screen_name']
        oauth_token = authorized_tokens['oauth_token']
        oauth_token_secret = authorized_tokens['oauth_token_secret']

        signals.tokens_received.send(sender=User.__class__,
                                     request=request,
                                     screen_name=screen_name,
                                     oauth_token=oauth_token,
                                     oauth_token_secret=oauth_token_secret)

        current_url = request.session.get('django.twitter.current_url', False)
        if current_url:
            self.url = current_url
            del request.session['django.twitter.current_url']

        return super(CallbackUrlView, self).get(request, *args, **kwargs)
コード例 #2
0
ファイル: views.py プロジェクト: GunioRobot/django-twitter
    def get_redirect_url(self, *kwargs):
        twitter = Twitter(twitter_token = settings.CONSUMER_KEY,
                          twitter_secret = settings.CONSUMER_SECRET)
        
        # Request an authorization url to send the user to
        auth_props = twitter.get_authentication_tokens()

        self.request.session['request_token'] = auth_props
        self.url = auth_props['auth_url']
        
        return super(RedirectToTwitterView, self).get_redirect_url(*kwargs)