Skip to content

Commit

Permalink
merging lib files
Browse files Browse the repository at this point in the history
  • Loading branch information
jessykate committed Nov 14, 2010
1 parent 1d138cb commit 4507f39
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
22 changes: 22 additions & 0 deletions api/lib.py
@@ -1,6 +1,28 @@
#!/usr/bin/python

import re, htmlentitydefs
from settings import BITLY_USER, BITLY_KEY
import urllib2, urllib
try:
import json
except:
import simplejson as json


def bitly_shorten(long_url):
# the long_url must contain the protocol
if not long_url.startswith('http://'):
long_url = 'http://' + long_url
base = "http://api.bit.ly/v3/shorten?"
args = {
'login': BITLY_USER,
'apiKey': BITLY_KEY,
'longUrl' : long_url,
}
api_call = base+urllib.urlencode(args)
fp = urllib2.urlopen(api_call)
js = json.loads(fp.read())
return js['data']['url']

def html_unescape(text):
''' Function by Fredrik Lundh at
Expand Down
25 changes: 0 additions & 25 deletions frontend/lib.py

This file was deleted.

0 comments on commit 4507f39

Please sign in to comment.