Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Quick script to check if you API credentials are communicating with x.com
- from twython import Twython
- from termcolor import colored
- consumer_key = "ADD YOUR KEY HERE"
- consumer_secret = "ADD YOUR KEY HERE"
- access_token = "ADD YOUR KEY HERE"
- access_token_secret = "ADD YOUR KEY HERE"
- # Authenticate?
- twitter = Twython(
- consumer_key,
- consumer_secret,
- access_token,
- access_token_secret
- )
- def check_api_status():
- try:
- user_info = twitter.verify_credentials()
- user_screen_name = user_info['screen_name']
- print(colored(f"API is working for user: {user_screen_name}", "green"))
- except Exception as e:
- print(colored(f"API is not working. Error: {e}", "red"))
- check_api_status()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement