Exemplo n.º 1
0
 def __get_request_unauthenticated__(self,endpoint,data):
     data = remove_nones(data)
     params = urllib.urlencode(data)
     full_uri = "%s?%s" % (endpoint,params)
     try:
         response = urllib2.urlopen(full_uri)
     except urllib2.HTTPError, e:
         raise TumblrError(e.__str__())
Exemplo n.º 2
0
 def __make_authenticated_request__(self,endpoint,data,method):
     try:
         data['api_key'] = self.authenticator.oauth_consumer_key
     except:
         raise TumblrError('This method requires instantiating the TumblrAPI with an oauth_consumer_key and secret_key or a TumblrAuthenticator')
     data = remove_nones(data)
     
     if method.lower() == 'get':
         params = urllib.urlencode(data)
         full_uri = "%s?%s" % (endpoint,params)
         log.debug('%s %s' % ('making request to',full_uri))
         try:
             response = urllib2.urlopen(full_uri)
         except urllib2.HTTPError, e:
             raise TumblrError(e.__str__())
Exemplo n.º 3
0
    def __make_oauth_request__(self,endpoint,data,method):
        try:
            access_token = self.authenticator.access_token
        except:
            raise TumblrError('This method requires obtaining and access token')
        #params = urllib.urlencode(data)
        data = remove_nones(data)
        log.debug('making %s request to %s with parameters %s' % (method,endpoint,data))
        
        response_text = self.authenticator.make_oauth_request(endpoint, method, parameters=data)

        log.debug('raw response: %s' % (response_text))
        response_text = to_unicode_or_bust(response_text, 'iso-8859-1')
        #if self.print_json:
        #    print response_text
        self.__check_for_tumblr_error__(response_text)
        
        return response_text