Skip to content

Instantly share code, notes, and snippets.

@SkyLeach
Created May 24, 2018 06:44
Show Gist options
  • Save SkyLeach/06c90cf546b7045d8ecc2f3388220444 to your computer and use it in GitHub Desktop.
Save SkyLeach/06c90cf546b7045d8ecc2f3388220444 to your computer and use it in GitHub Desktop.
Bitly Temp Applink
#!/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