Last active
October 30, 2022 19:23
-
-
Save n1ckfg/0a5eb7cc19af5d123cd07139b9faaa32 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
| # https://www.geeksforgeeks.org/python-tweepy-getting-the-id-of-a-user/ | |
| import tweepy | |
| consumer_key = "" | |
| consumer_secret = "" | |
| access_token = "" | |
| access_token_secret = "" | |
| auth = tweepy.OAuthHandler(consumer_key, consumer_secret) | |
| auth.set_access_token(access_token, access_token_secret) | |
| api = tweepy.API(auth) | |
| test_screen_name = "geeksforgeeks" | |
| test_id = 57741058 | |
| user_by_screen_name = api.get_user(screen_name=test_screen_name) | |
| user_by_id = api.get_user(user_id=test_id) | |
| print("The ID of the user [ " + test_screen_name + " ] is: " + user_by_screen_name.id_str) | |
| print("The screen name of user id [ " + str(test_id) + " ] is: " + user_by_id.screen_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment