Demo entry 6783111

test

   

Submitted by anonymous on Jan 30, 2019 at 00:30
Language: Python 3. Code size: 493 Bytes.

#!/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']

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).