Created
October 11, 2019 18:25
-
-
Save FBosler/fb65cc2e669a1b4c339d5b808e53c8e6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tweepy | |
from bots.config import get_config | |
__API = None | |
def configure_twitter_api(): | |
API_KEY = get_config()['API_KEY'] | |
API_KEY_SECRET = get_config()['API_KEY_SECRET'] | |
ACCESS_TOKEN = get_config()['ACCESS_TOKEN'] | |
ACCESS_TOKEN_SECRET = get_config()['ACCESS_TOKEN_SECRET'] | |
auth = tweepy.OAuthHandler(API_KEY, API_KEY_SECRET) | |
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET) | |
api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True) | |
return api | |
def get_twitter_api(): | |
global __API | |
if not __API: | |
__API = configure_twitter_api() | |
return __API |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment