本文整理汇总了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)
示例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)
示例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
示例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)
示例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
示例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
示例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
示例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)
示例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
示例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()
示例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
示例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
示例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
示例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)
示例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])