Python tweepy.AppAuthHandler() Examples
The following are 4
code examples of tweepy.AppAuthHandler().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tweepy
, or try the search function
.
Example #1
Source File: __init__.py From botometer-python with MIT License | 5 votes |
def __init__(self, consumer_key, consumer_secret, access_token=None, access_token_secret=None, rapidapi_key=None, **kwargs): self.consumer_key = consumer_key self.consumer_secret = consumer_secret self.access_token_key = self.access_token = access_token self.access_token_secret = access_token_secret self.wait_on_ratelimit = kwargs.get('wait_on_ratelimit', False) self.rapidapi_key = rapidapi_key or kwargs.get('mashape_key') if self.access_token_key is None or self.access_token_secret is None: auth = tweepy.AppAuthHandler( self.consumer_key, self.consumer_secret) else: auth = tweepy.OAuthHandler( self.consumer_key, self.consumer_secret) auth.set_access_token( self.access_token_key, self.access_token_secret) self.twitter_api = tweepy.API( auth, parser=tweepy.parsers.JSONParser(), wait_on_rate_limit=self.wait_on_ratelimit, ) self.api_url = kwargs.get('botometer_api_url', 'https://botometer-pro.p.rapidapi.com') self.api_version = kwargs.get('botometer_api_version', 2)
Example #2
Source File: tweepy_pool.py From smappPy with GNU General Public License v2.0 | 5 votes |
def _get_tweepy_appauth_handler(self, oauth_dict): try: return tweepy.AppAuthHandler(oauth_dict["consumer_key"], oauth_dict["consumer_secret"]) except TweepError: print TweepError
Example #3
Source File: tweetlord.py From tweetlord with GNU General Public License v3.0 | 5 votes |
def tweepy_auth(cred, mode): auth = None if mode == 'user': auth = tweepy.OAuthHandler(cred['consumer_key'], cred['consumer_secret']) auth.set_access_token(cred['access_token_key'], cred['access_token_secret']) elif mode == 'app': auth = tweepy.AppAuthHandler(cred['consumer_key'], cred['consumer_secret']) return tweepy.API(auth, wait_on_rate_limit=False) if auth else None # ---------------------------------------------------------- # -------------------- Account Manager --------------------- # ----------------------------------------------------------
Example #4
Source File: find_amplification_bots.py From twitterbots with BSD 3-Clause "New" or "Revised" License | 4 votes |
def main(): consumer_key = os.environ.get('TWEEPY_CONSUMER_KEY') consumer_secret = os.environ.get('TWEEPY_CONSUMER_SECRET') api_auth = AppAuthHandler(consumer_key, consumer_secret) app_api = API(api_auth, wait_on_rate_limit_notify=True, wait_on_rate_limit=True) # Set up the database database_path = 'amplification.db' engine = create_engine('sqlite:///{}'.format(database_path)) session_factory = sessionmaker(bind=engine) session = scoped_session(session_factory) Base.metadata.create_all(engine) args = parse_args() try: crawler = Queue() crawler.put(args.seed_acount) accounts_seen = set() while not crawler.empty(): account_id = crawler.get() tweets = get_tweets(app_api, account_id) tweet_crawl_date = datetime.utcnow() prioritized_list = process_tweets(tweets) for item in prioritized_list: tweet = item[1] author = tweet['user'] logger.info('Found {} amplified tweets from {}'.format( len(prioritized_list), author['screen_name'])) tweet_node = add_tweet_node(session, tweet['id'], author['id'], author['screen_name'], tweet['text'], tweet_crawl_date) retweeters = get_retweeters(app_api, tweet['id']) for retweeter in retweeters: retweeter_id = retweeter['id'] if not is_retweet_bot(app_api, retweeter_id): continue logger.info('\tPotential retweet bot: {}'.format(retweeter['screen_name'])) account_crawl_date = datetime.utcnow() account_node = add_account_node(session, retweeter['id'], retweeter['screen_name'], account_crawl_date) add_edge(session, account_node, tweet_node) if retweeter_id in accounts_seen: continue accounts_seen.add(retweeter_id) crawler.put(retweeter_id) except KeyboardInterrupt: print('CTRL+C received... shutting down')