import twitter import os from app_be.models import Tweet from dotenv import load_dotenv load_dotenv() api = twitter.Api(consumer_key=os.getenv('TWITTER_API_KEY'), consumer_secret=os.getenv('TWITTER_API_SECRET'), access_token_key=os.getenv('TWITTER_ACCESS_TOKEN'), access_token_secret=os.getenv('TWITTER_ACCESS_TOKEN_SECRET')) class twitter_api: @staticmethod def check_credentials(): print(api.VerifyCredentials()) @staticmethod def get_last_six_tweets(): last_six = Tweet.objects.all().order_by('-id')[:6] print(last_six) @staticmethod def get_last_twelve_tweets(): last_twelve = Tweet.objects.all().order_by('-id')[:12] print(last_twelve) @staticmethod def post_update(text, url): update = text + ": " + url api.PostUpdate(update)