def _initialize_api(self):
"""
Handles authentication with Twitter API using tweepy.
Requires a file at config/twitter_creds.json with the following attributes:
"access_token":
"access_secret":
"consumer_token":
"consumer_secret":
See Twitter OAUTH docs + Tweepy docs for more details http://docs.tweepy.org/en/v3.5.0/auth_tutorial.html
:return:
"""
with open(self.loc.format('../config/twitter_creds.json')) as fp:
config = json.load(fp)
auth = tweepy.OAuthHandler(config['consumer_token'], config['consumer_secret'])
auth.set_access_token(config['access_token'], config['access_secret'])
self.logger.info('Successfully Authenticated to Twitter API')
self.api = tweepy.API(auth)
评论列表
文章目录