def AddShortLink(blip, wave_id): wave_url = "https://wave.google.com/wave/#restored:wave:%s" % wave_id wave_url = wave_url.replace("#", "%23") wave_url = wave_url.replace("+", "%252B") bitly = BitLy(bitlycred.LOGIN, bitlycred.KEY) short_url = bitly.shorten(wave_url) ModBlip(blip, short_url, [("link/manual", short_url), ("style/fontSize", "1.5em")]) ModBlip(blip, "\n", [("link/manual", None), ("style/fontSize", None)])
def AddShortLink(blip, wave_id): wave_url = 'https://wave.google.com/wave/#restored:wave:%s' % wave_id wave_url = wave_url.replace('#', '%23') wave_url = wave_url.replace('+', '%252B') bitly = BitLy(bitlycred.LOGIN, bitlycred.KEY) short_url = bitly.shorten(wave_url) ModBlip(blip, short_url, [('link/manual', short_url), ('style/fontSize', '1.5em')]) ModBlip(blip, '\n', [('link/manual', None), ('style/fontSize', None)])
def testshorten(self): bitly = BitLy(BITLY_LOGIN, BITLY_API_KEY) url = 'www.yahoo.com' self.assertEquals('http://bit.ly/bxUHoc', bitly.shorten(url)['results']['http://' + url]['shortUrl']) self.assertEquals(2, bitly.stats('http://bit.ly/bxUHoc')['results']['userClicks'])
def buildbitlyshortener(): bitly = BitLy(BITLY_LOGIN, BITLY_API_KEY) return lambda x:bitly.shorten(x.replace('http://', ''))['results']['http://' + x.replace('http://', '')]['shortUrl']
def testShortenURL(self): bitly = BitLy(bitlycred.LOGIN, bitlycred.KEY) short_url = bitly.shorten("http://www.chrishannam.co.uk") print short_url
def testShortenURL(self): bitly = BitLy(bitlycred.LOGIN, bitlycred.KEY) short_url = bitly.shorten('http://www.chrishannam.co.uk') print short_url