twitter/bitly.py
def shorten(self,longURL):
        """ 
            Takes either:
            A long URL string and returns shortened URL string
            Or a list of long URL strings and returns a list of shortened URL strings.
        """
        if not isinstance(longURL, list):
            longURL = [longURL]
        
        for index,url in enumerate(longURL):
            if not '://' in url:
                longURL[index] = "http://" + url
            
        request = self._getURL("shorten",longURL)
        result = self._fetchUrl(request)
        json = simplejson.loads(result)
        self._CheckForError(json)
        
        res = []
        for item in json['results'].values():
            if item['shortKeywordUrl'] == "":
                res.append(item['shortUrl'])
            else:
                res.append(item['shortKeywordUrl'])
        
        if len(res) == 1:
            return res[0]
        else:
            return res
 
            Takes either:
            A long URL string and returns shortened URL string
            Or a list of long URL strings and returns a list of shortened URL strings.
        
Takes either:
A long URL string and returns shortened URL string
Or a list of long URL strings and returns a list of shortened URL strings.
Takes either : A long URL string and returns shortened URL string Or a list of long URL strings and returns a list of shortened URL strings .
def shorten(self,longURL):
        if not isinstance(longURL, list):
            longURL = [longURL]
        for index,url in enumerate(longURL):
            if not '://' in url:
                longURL[index] = "http://" + url
        request = self._getURL("shorten",longURL)
        result = self._fetchUrl(request)
        json = simplejson.loads(result)
        self._CheckForError(json)
        res = []
        for item in json['results'].values():
            if item['shortKeywordUrl'] == "":
                res.append(item['shortUrl'])
            else:
                res.append(item['shortKeywordUrl'])
        if len(res) == 1:
            return res[0]
        else:
            return res
def shorten ( self , longURL ) : if not isinstance ( longURL , list ) : longURL = [ longURL ] for index , url in enumerate ( longURL ) : if not '://' in url : longURL [ index ] = "http://" + url request = self . _getURL ( "shorten" , longURL ) result = self . _fetchUrl ( request ) json = simplejson . loads ( result ) self . _CheckForError ( json ) res = [ ] for item in json [ 'results' ] . values ( ) : if item [ 'shortKeywordUrl' ] == "" : res . append ( item [ 'shortUrl' ] ) else : res . append ( item [ 'shortKeywordUrl' ] ) if len ( res ) == 1 : return res [ 0 ] else : return res
Takes either:
A long URL string and returns shortened URL string
Or a list of long URL strings and returns a list of shortened URL strings.
Takes either : A long URL string and returns shortened URL string Or a list of long URL strings and returns a list of shortened URL strings .
""" 
            Takes either:
            A long URL string and returns shortened URL string
            Or a list of long URL strings and returns a list of shortened URL strings.
        """
self
longURL