Created
December 3, 2013 16:42
-
-
Save utecht/7772574 to your computer and use it in GitHub Desktop.
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
import requests | |
import sys | |
import webbrowser | |
from base64 import b64encode | |
api_key = 'c4622163d7339fe' | |
headers = {"Authorization": "Client-ID {}".format(api_key)} | |
url = "https://api.imgur.com/3/upload.json" | |
f = sys.argv[1] | |
j1 = requests.post( | |
url, | |
headers = headers, | |
data = { | |
'key': api_key, | |
'image': b64encode(open(f, 'rb').read()), | |
'type': 'base64', | |
'name': f, | |
'title': 'Picture no. 1' | |
} | |
) | |
if(j1.json()['success']): | |
webbrowser.open(j1.json()['data']['link']) | |
else: | |
print(j1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment