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:
parent
9a13b0ae3f
commit
10c32e427c
1 changed files with 6 additions and 0 deletions
6
tango.py
6
tango.py
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue