Advertisement
zeromega64twenty

x.com X Twitter Authentication Tester

Aug 30th, 2023 (edited)
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | Source Code | 0 0
  1. # Quick script to check if you API credentials are communicating with x.com
  2. from twython import Twython
  3. from termcolor import colored
  4.  
  5. consumer_key = "ADD YOUR KEY HERE"
  6. consumer_secret = "ADD YOUR KEY HERE"
  7. access_token = "ADD YOUR KEY HERE"
  8. access_token_secret = "ADD YOUR KEY HERE"
  9.  
  10. # Authenticate?
  11. twitter = Twython(
  12.     consumer_key,
  13.     consumer_secret,
  14.     access_token,
  15.     access_token_secret
  16. )
  17.  
  18. def check_api_status():
  19.     try:
  20.         user_info = twitter.verify_credentials()
  21.         user_screen_name = user_info['screen_name']
  22.         print(colored(f"API is working for user: {user_screen_name}", "green"))
  23.     except Exception as e:
  24.         print(colored(f"API is not working. Error: {e}", "red"))
  25.  
  26. check_api_status()
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement