def __init__(self, twitter_username):
# TODO: Login to twitter for corpus generation using end user's credentials
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
# Connect to Twitter - raise TweepError if we brick out on this
try:
api = tweepy.API(auth)
except tweepy.TweepError:
# TODO: make sure this error bubbles up and gets handled gracefully
raise PermissionError("Twitter Auth failed")
usr = api.get_user(twitter_username)
self.username = twitter_username
self.image = usr.profile_image_url
# Exposes entire api - for debugging only
# self.api = usr
self.description = usr.description
self.screen_name = usr.screen_name
self.name = usr.name
评论列表
文章目录