Last active
November 28, 2022 04:29
-
-
Save plusreed/532ccc8ea3077de6651caadd206da353 to your computer and use it in GitHub Desktop.
Upload a transparent Twitter profile picture
This file contains 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
# You'll need Tweepy and a Twitter dev account. | |
# Your image should, preferably, be under 1000 pixels on either dimension (width and height.) | |
# Should also be under 700KB. | |
# This script is very hit-or-miss. GLHF. | |
from tweepy import OAuth1UserHandler, API | |
APIKEY = "" | |
APIKEYSECRET = "" | |
oauth1 = OAuth1UserHandler( | |
APIKEY, | |
APIKEYSECRET, | |
callback="oob" # forces usage of PIN auth | |
) | |
print(f"Login: {oauth1.get_authorization_url()}") | |
verifier = input("Input the PIN you got from Twitter: ") | |
access_token, access_token_secret = oauth1.get_access_token(verifier) | |
api = API(oauth1) | |
print("Logged in!") | |
# You could also replace this line with the file path yourself. | |
# Just using input here for ease. | |
path_to_image = input("Path to image: ") | |
ok = None | |
# open file | |
with open(path_to_image, "rb") as image_file: | |
print("Upload this image as your profile picture?") | |
print("For the best results, your profile picture should be below 1000x1000 and be under 700KB.") | |
ok = input("y/n: ") | |
if ok == "y" or ok == None: | |
print("Uploading...") | |
# upload image as profile picture | |
api.update_profile_image(path_to_image, file=image_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment