当前位置: 首页>>代码示例>>Python>>正文


Python auth.OAuthHandler类代码示例

本文整理汇总了Python中tweepy.auth.OAuthHandler的典型用法代码示例。如果您正苦于以下问题:Python OAuthHandler类的具体用法?Python OAuthHandler怎么用?Python OAuthHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了OAuthHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: register

def register(request):
    if request.method == 'POST':
        form = FundRaiserRegistration(request.POST)
        if form.is_valid():
            # partially create user, and store unauthed token
            user = _user_from_reg_form(form)
            try:
                profile = _profile_from_reg_form(form, user)
            except ValueError:
                return HttpResponse('that page is already registered')

            request.session['user_id'] = user.pk
            handler = OAuthHandler(settings.TWITTER_CONSUMER_KEY,
                    settings.TWITTER_CONSUMER_SECRET,
                    callback='http://www.justgivingthanks.com/callback/',
                    secure=True)
            auth_url = handler.get_authorization_url()
            request.session['unauthed_token'] = handler.request_token.to_string()
            print 'created user, got token, redirecting to %s' % (auth_url)
            return HttpResponseRedirect(auth_url)
    else:
        form = FundRaiserRegistration() # An unbound form

    return render_to_response('registration.html',
            {'form': form},
            context_instance=RequestContext(request))
开发者ID:gareth-lloyd,项目名称:tweetrace,代码行数:26,代码来源:views.py

示例2: TweepyStreamBackoffTests

class TweepyStreamBackoffTests(unittest.TestCase):
    def setUp(self):
        #bad auth causes twitter to return 401 errors
        self.auth = OAuthHandler("bad-key", "bad-secret")
        self.auth.set_access_token("bad-token", "bad-token-secret")
        self.listener = MockStreamListener(self)
        self.stream = Stream(self.auth, self.listener)

    def tearDown(self):
        self.stream.disconnect()

    def test_exp_backoff(self):
        self.stream = Stream(self.auth, self.listener, timeout=3.0,
                             retry_count=1, retry_time=1.0, retry_time_cap=100.0)
        self.stream.sample()
        # 1 retry, should be 4x the retry_time
        self.assertEqual(self.stream.retry_time, 4.0)

    def test_exp_backoff_cap(self):
        self.stream = Stream(self.auth, self.listener, timeout=3.0,
                             retry_count=1, retry_time=1.0, retry_time_cap=3.0)
        self.stream.sample()
        # 1 retry, but 4x the retry_time exceeds the cap, so should be capped
        self.assertEqual(self.stream.retry_time, 3.0)

    mock_resp = MagicMock()
    mock_resp.return_value.status = 420

    @patch(getresponse_location, mock_resp)
    def test_420(self):
        self.stream = Stream(self.auth, self.listener, timeout=3.0, retry_count=0,
                             retry_time=1.0, retry_420=1.5, retry_time_cap=20.0)
        self.stream.sample()
        # no retries, but error 420, should be double the retry_420, not double the retry_time
        self.assertEqual(self.stream.retry_time, 3.0)
开发者ID:GoNexia,项目名称:tweepy,代码行数:35,代码来源:test_streaming.py

示例3: filter_track

def filter_track(follow):
    auth = OAuthHandler(consumer_key2, consumer_secret2)
    auth.set_access_token(access_token2, access_token_secret2)
    stream = Stream(auth, MyStreamListener())
    api = API(auth)
    #print 'start filter track ', ','.join(track)
    stream.filter(track=follow)
开发者ID:LookThisCode,项目名称:NextLevelLatAm,代码行数:7,代码来源:twitter_polling.py

示例4: __init__

 def __init__(self, api_key, api_key_secret, access_token, token_secret):
     '''
         Initialize the twitter API client.
     '''
     auth_handler = OAuthHandler(api_key, api_key_secret)
     auth_handler.set_access_token(access_token, token_secret)
     self.twitter_client = API(auth_handler)
开发者ID:tanwanirahul,项目名称:twitter-carnival,代码行数:7,代码来源:core.py

示例5: get_oauth

def get_oauth():
    conf = ConfigParser.SafeConfigParser()
    conf.read("twitter.ini")
    auth = OAuthHandler(conf.get("Twitter", "CK"), conf.get("Twitter", "CS"))
    auth.set_access_token(conf.get("Twitter", "AT"), conf.get("Twitter", "AS"))

    return auth
开发者ID:KyosukeHagiwara,项目名称:Komiyama,代码行数:7,代码来源:Komiyama.py

示例6: get_oauth

def get_oauth():
  consumer_key = ''
  consumer_secret = ''
  access_key = ''
  access_secret = ''
  auth = OAuthHandler(consumer_key, consumer_secret)
  auth.set_access_token(access_key, access_secret)
  return auth
开发者ID:bynnchapu,项目名称:ThermalPrinter_SM1-21,代码行数:8,代码来源:lol.py

示例7: cmd_get_auth_url

def cmd_get_auth_url(bot, update, chat):
    auth = OAuthHandler(bot.tw.auth.consumer_key, bot.tw.auth.consumer_secret)
    auth_url = auth.get_authorization_url()
    chat.twitter_request_token = json.dumps(auth.request_token)
    chat.save()
    msg = "go to [this url]({}) and send me your verifier code using /verify code"
    bot.reply(update, msg.format(auth_url),
              parse_mode=telegram.ParseMode.MARKDOWN)
开发者ID:trinhvv,项目名称:telegram-twitter-forwarder-bot,代码行数:8,代码来源:commands.py

示例8: get_oauth

def get_oauth():
	consumer_key = keys.twKeys['consumer_key'].encode('utf-8')
	consumer_secret = keys.twKeys['consumer_secret'].encode('utf-8')
	access_key = keys.twKeys['access_token'].encode('utf-8')
	access_secret = keys.twKeys['access_secret'].encode('utf-8')
	auth = OAuthHandler(consumer_key, consumer_secret)
	auth.set_access_token(access_key, access_secret)
	return auth
开发者ID:jschatbot,项目名称:team_lou,代码行数:8,代码来源:twapi.py

示例9: _setup_apis

    def _setup_apis(self):
        auth = OAuthHandler(self._consumer_key, self._consumer_secret)
        auth.set_access_token(self._access_token, self._access_token_secret)

        if self._raw_json:
            self._api = TwitterAPI(auth, parser=RawParser())
        else:
            self._api = TwitterAPI(auth)
开发者ID:ojos,项目名称:python2.x-library,代码行数:8,代码来源:twitter.py

示例10: oauth

def oauth():
    consumer_key = ""
    consumer_secret = ""
    access_token = ""
    access_token_secret = ""
    auth = OAuthHandler(consumer_key, consumer_secret)
    auth.set_access_token(access_token, access_token_secret)
    return auth
开发者ID:huu12,项目名称:markov_bot,代码行数:8,代码来源:main.py

示例11: get_oauth

def get_oauth():
    consumer_key = 'TWITTER_CONSUMER_KEY'
    consumer_secret = 'TWITTER_CONSUMER_SECRET'
    access_key = 'TWITTER_ACCESS_KEY'
    access_secret = 'TWITTER_ACCESS_SECRET'
    auth = OAuthHandler(consumer_key, consumer_secret)
    auth.set_access_token(access_key, access_secret)
    return auth
开发者ID:necoma,项目名称:matatabi_script,代码行数:8,代码来源:TwitterStreamingWatcher.py

示例12: get_auth_url

    def get_auth_url(self, params={}, callback_url=None):
        if callback_url is None:
            callback_url = self._callback_url
        callback = '%s?%s' % (callback_url, urllib.urlencode(params))
        auth = OAuthHandler(self._consumer_key, self._consumer_secret, callback)
        url = auth.get_authorization_url()

        return url, auth.request_token
开发者ID:ojos,项目名称:python2.x-library,代码行数:8,代码来源:twitter.py

示例13: _get_rate_limit_status

 def _get_rate_limit_status(self, key, secret):
     """
     Get rate limit status for specified access token key.
     """
     auth = OAuthHandler(self.consumer_key, self.consumer_secret)
     auth.set_access_token(key, secret)
     api = API(auth)
     return api.rate_limit_status()
开发者ID:svven,项目名称:tweepy,代码行数:8,代码来源:limit.py

示例14: get_oauth

 def get_oauth(self,):
     consumer_key = self.consumer['key']
     consumer_secret = self.consumer['secret']
     access_token = self.token['token']
     access_secret = self.token['secret']
     auth = OAuthHandler(consumer_key, consumer_secret)
     auth.set_access_token(access_token, access_secret)
     return auth
开发者ID:shimaXX,项目名称:workspace,代码行数:8,代码来源:twitterAPI.py

示例15: filter_track

def filter_track():
    q = Scrapers.all().filter('','')
    follow=[s.uid for s in q]
    auth = OAuthHandler(consumer_key, consumer_secret)
    auth.set_access_token(access_token, access_token_secret)
    stream = Stream(auth, MyStreamListener())
    api = API(auth)
    #print 'start filter track ', ','.join(track)
    stream.filter(follow=follow)
开发者ID:LookThisCode,项目名称:NextLevelLatAm,代码行数:9,代码来源:twitter_polling.py


注:本文中的tweepy.auth.OAuthHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。