From Bulky Owl, 10 Years ago, written in Plain Text.
Embed
  1. #!/usr/bin/env python
  2.  
  3. # Import the modules
  4.  
  5. import bitlyapi
  6. import sys
  7.  
  8. # Define your API information
  9.  
  10. API_USER = "your_api_username"
  11. API_KEY = "your_api_key"
  12.  
  13. b = bitlyapi.BitLy(API_USER, API_KEY)
  14.  
  15. # Define how to use the program
  16.  
  17. usage = """Usage: python shortener.py [url]
  18. e.g python shortener.py http://www.google.com"""
  19.  
  20. if len(sys.argv) != 2:
  21.     print usage
  22.     sys.exit(0)
  23.  
  24. longurl = sys.argv[1]
  25.  
  26. response = b.shorten(longUrl=longurl)
  27.  
  28. print response['url']

Replies to Untitled rss

Title Name Language When
Re: Untitled Scanty Curlew python 10 Years ago.