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


Python OAuthHandler.set_access_token方法代码示例

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


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

示例1: filter_track

# 需要导入模块: from tweepy.auth import OAuthHandler [as 别名]
# 或者: from tweepy.auth.OAuthHandler import set_access_token [as 别名]
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,代码行数:9,代码来源:twitter_polling.py

示例2: TweepyStreamBackoffTests

# 需要导入模块: from tweepy.auth import OAuthHandler [as 别名]
# 或者: from tweepy.auth.OAuthHandler import set_access_token [as 别名]
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,代码行数:37,代码来源:test_streaming.py

示例3: get_oauth

# 需要导入模块: from tweepy.auth import OAuthHandler [as 别名]
# 或者: from tweepy.auth.OAuthHandler import set_access_token [as 别名]
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,代码行数:9,代码来源:Komiyama.py

示例4: __init__

# 需要导入模块: from tweepy.auth import OAuthHandler [as 别名]
# 或者: from tweepy.auth.OAuthHandler import set_access_token [as 别名]
 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,代码行数:9,代码来源:core.py

示例5: oauth

# 需要导入模块: from tweepy.auth import OAuthHandler [as 别名]
# 或者: from tweepy.auth.OAuthHandler import set_access_token [as 别名]
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,代码行数:10,代码来源:main.py

示例6: get_oauth

# 需要导入模块: from tweepy.auth import OAuthHandler [as 别名]
# 或者: from tweepy.auth.OAuthHandler import set_access_token [as 别名]
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,代码行数:10,代码来源:lol.py

示例7: get_oauth

# 需要导入模块: from tweepy.auth import OAuthHandler [as 别名]
# 或者: from tweepy.auth.OAuthHandler import set_access_token [as 别名]
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,代码行数:10,代码来源:twapi.py

示例8: _setup_apis

# 需要导入模块: from tweepy.auth import OAuthHandler [as 别名]
# 或者: from tweepy.auth.OAuthHandler import set_access_token [as 别名]
    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,代码行数:10,代码来源:twitter.py

示例9: get_oauth

# 需要导入模块: from tweepy.auth import OAuthHandler [as 别名]
# 或者: from tweepy.auth.OAuthHandler import set_access_token [as 别名]
 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,代码行数:10,代码来源:twitterAPI.py

示例10: _get_rate_limit_status

# 需要导入模块: from tweepy.auth import OAuthHandler [as 别名]
# 或者: from tweepy.auth.OAuthHandler import set_access_token [as 别名]
 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,代码行数:10,代码来源:limit.py

示例11: get_oauth

# 需要导入模块: from tweepy.auth import OAuthHandler [as 别名]
# 或者: from tweepy.auth.OAuthHandler import set_access_token [as 别名]
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,代码行数:10,代码来源:TwitterStreamingWatcher.py

示例12: get_oauth

# 需要导入模块: from tweepy.auth import OAuthHandler [as 别名]
# 或者: from tweepy.auth.OAuthHandler import set_access_token [as 别名]
def get_oauth():
    # 以下4つのキー等は適宜取得して置き換えてください。
    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:c-bata,项目名称:arduino_code,代码行数:11,代码来源:twitter_timeline.py

示例13: getOauth

# 需要导入模块: from tweepy.auth import OAuthHandler [as 别名]
# 或者: from tweepy.auth.OAuthHandler import set_access_token [as 别名]
def getOauth():
	consumerKey = 'jCLoeEVXxq4ygfPsJma33jUTN'
	consumerSecret = 'yPSDOl17fqBqaSKfDa8rDlaHaHBZ6llyClcLRO1G3kV6cIWnWz'
	accessKey = '495476602-OalwRLSU9poetl3HuQiX9AZ8tcd9QQuhfHLjQ8xf'
	accessSecret = 'bQhekPGvSn87VmxSuPtP8ODCXFzZKJ1zoZnRvMThVLNof'
 
	auth = OAuthHandler(consumerKey, consumerSecret)
	auth.set_access_token(accessKey, accessSecret)
	return auth
开发者ID:ace12358,项目名称:100knock,代码行数:11,代码来源:testtimeline2.py

示例14: filter_track

# 需要导入模块: from tweepy.auth import OAuthHandler [as 别名]
# 或者: from tweepy.auth.OAuthHandler import set_access_token [as 别名]
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,代码行数:11,代码来源:twitter_polling.py

示例15: main_logger

# 需要导入模块: from tweepy.auth import OAuthHandler [as 别名]
# 或者: from tweepy.auth.OAuthHandler import set_access_token [as 别名]
def main_logger(basename=None):
        l = RotatingLogListener(basename=basename)
        auth = OAuthHandler(consumer_key, consumer_secret)
        auth.set_access_token(access_token, access_token_secret)
        stream = Stream(auth, l)

        # This fetches ANY geotagged tweet:
        # https://dev.twitter.com/docs/streaming-apis/parameters#locations
        stream.filter(locations=[-180,-90,180,90])
开发者ID:chebee7i,项目名称:twitter,代码行数:11,代码来源:stream.py


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