コード例 #1
0
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)])
コード例 #2
0
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)])
コード例 #3
0
ファイル: admin.py プロジェクト: dudarev/osmtweet
 def PrepareHandler(self):
     """prepare means: 
     - find the oldest non-prepared
     - create bit.ly link if does not exist
     - create trimmed tweet text if the link exists"""
     config = get_config()
     self.response.out.write('<br/><br/>Preparing to tweet')
     # get oldest non-prepared changeset in the datastore
     oldest_changeset = Changeset.all().order('created_at').filter('is_prepared =', False).fetch(1)
     if oldest_changeset:
         c = oldest_changeset[0]
         self.response.out.write('<br/>There is non-prepared<br/>')
         self.response.out.write("id: %d<br/>" % c.id)
         self.response.out.write("created_at: %s<br/>" % c.created_at)
         self.response.out.write("comment: %s<br/>" % c.comment)
         self.response.out.write("user: %s<br/>" % c.user)
         # if no shortened link - create it
         if not c.link_url:
             long_url = "http://www.openstreetmap.org/browse/changeset/%d" % c.id
             bitly = BitLy(config["bitly_username"], config["bitly_key"])
             short_url = bitly.short_url(long_url)
             if not short_url:
                 self.response.out.write('could not shorten')
                 return
             self.response.out.write(short_url)
             c.link_url = short_url
         if not c.tweet:
             if c.comment:
                 tweet = "%s: %s %s" % (c.user, c.comment, c.link_url)
             else:
                 tweet = "%s: %s" % (c.user, c.link_url)
         c.tweet = trim_to_tweet(tweet)
         if c.link_url and c.tweet:
             c.is_prepared = True
         self.response.out.write('tweet: %s' % c.tweet)
         c.put()
コード例 #4
0
ファイル: bitlytest.py プロジェクト: mattorb/feedertweeter
 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'])
コード例 #5
0
ファイル: tweetwriter.py プロジェクト: mattorb/feedertweeter
def buildbitlyshortener():
    bitly = BitLy(BITLY_LOGIN, BITLY_API_KEY)
    return lambda x:bitly.shorten(x.replace('http://', ''))['results']['http://' + x.replace('http://', '')]['shortUrl']
コード例 #6
0
 def testShortenURL(self):
     bitly = BitLy(bitlycred.LOGIN, bitlycred.KEY)
     short_url = bitly.shorten("http://www.chrishannam.co.uk")
     print short_url
コード例 #7
0
 def testShortenURL(self):
     bitly = BitLy(bitlycred.LOGIN, bitlycred.KEY)
     short_url = bitly.shorten('http://www.chrishannam.co.uk')
     print short_url