def oauth_initialize(): # twitter credential db bot = TwitterBot.get() if not bot: bot = TwitterBot() bot.consumer_key = app.config['CONSUMER_KEY'] bot.consumer_secret = app.config['CONSUMER_SECRET'] bot.complete = 0 bot.enabled = 0 bot.flavor_id = 0 bot.max_instances = app.config['MAX_INSTANCES_DEFAULT'] bot.announce = 0 bot.updated = int(time.time()) # give twitter a holler try: twitter = Twitter(auth=OAuth("", "", bot.consumer_key, bot.consumer_secret), format="", api_version=None) # screen name won't be set until oauth_complete runs oauth_token, oauth_token_secret, screen_name = parse_oauth_tokens( twitter.oauth.request_token()) oauth_url = "https://api.twitter.com/oauth/authorize?oauth_token=%s" % oauth_token except Exception as ex: return bot # update the entries with what we got back bot.oauth_token = oauth_token bot.oauth_token_secret = oauth_token_secret bot.oauth_url = oauth_url bot.screen_name = screen_name bot.complete = 1 bot.enabled = 0 bot.flavor_id = 0 bot.max_instances = app.config['MAX_INSTANCES_DEFAULT'] bot.announce = 0 bot.updated = int(time.time()) bot.update() return bot
def oauth_initialize(): # twitter credential db bot = TwitterBot.get() if not bot: bot = TwitterBot() bot.consumer_key = app.config["CONSUMER_KEY"] bot.consumer_secret = app.config["CONSUMER_SECRET"] bot.complete = 0 bot.enabled = 0 bot.flavor_id = 0 bot.max_instances = app.config["MAX_INSTANCES_DEFAULT"] bot.announce = 0 bot.updated = int(time.time()) # give twitter a holler try: twitter = Twitter(auth=OAuth("", "", bot.consumer_key, bot.consumer_secret), format="", api_version=None) # screen name won't be set until oauth_complete runs oauth_token, oauth_token_secret, screen_name = parse_oauth_tokens(twitter.oauth.request_token()) oauth_url = "https://api.twitter.com/oauth/authorize?oauth_token=%s" % oauth_token except Exception as ex: return bot # update the entries with what we got back bot.oauth_token = oauth_token bot.oauth_token_secret = oauth_token_secret bot.oauth_url = oauth_url bot.screen_name = screen_name bot.complete = 1 bot.enabled = 0 bot.flavor_id = 0 bot.max_instances = app.config["MAX_INSTANCES_DEFAULT"] bot.announce = 0 bot.updated = int(time.time()) bot.update() return bot