Added a URL shortening method that hits the is.gd API, random comments sprinkled throughout - coming along nicely. Perhaps fallbacks should be provided for when the is.gd API limit is reached?

This commit is contained in:
Ryan McGrath 2009-05-21 03:17:47 -04:00
parent 9a13b0ae3f
commit 10c32e427c

View file

@ -11,6 +11,7 @@ try:
except:
print "Tango requires the simplejson library to work. http://www.undefined.org/python/"
# Should really deprecate httplib2 at some point...
try:
import httplib2
except:
@ -41,6 +42,11 @@ class setup:
else:
pass
def shortenURL(self, url_to_shorten):
# Perhaps we should have fallbacks here in case the is.gd API limit gets hit? Maybe allow them to set the host?
shortURL = urllib2.urlopen("http://is.gd/api.php?" + urllib.urlencode({"longurl": url_to_shorten})).read()
return shortURL
def constructApiURL(self, base_url, params):
queryURL = base_url
questionMarkUsed = False