Created
May 24, 2018 06:44
-
-
Save SkyLeach/06c90cf546b7045d8ecc2f3388220444 to your computer and use it in GitHub Desktop.
Bitly Temp Applink
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
#!/usr/bin/env python | |
# Import the modules | |
import bitlyapi | |
import sys | |
# Define your API information | |
API_USER = "your_api_username" | |
API_KEY = "your_api_key" | |
b = bitlyapi.BitLy(API_USER, API_KEY) | |
# Define how to use the program | |
usage = """Usage: python shortener.py [url] | |
e.g python shortener.py http://www.google.com""" | |
if len(sys.argv) != 2: | |
print usage | |
sys.exit(0) | |
longurl = sys.argv[1] | |
response = b.shorten(longUrl=longurl) | |
print response['url'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment