Esempio n. 1
0
    def __get_internal(self, query=None, content_type='photos'):
        if self._access_token is None:
            raise RequiresAccessTokenError()
        
        base_url = CONTENT_ROOT_URL + "/" + content_type + '/'
        parameters = {}
        if query is not None:
            query_post = simplejson.dumps(query, cls=JSONFactories.encoders.get_encoder_for(query))
            parameters['query'] = query_post

        response = self.__make_oauth2_request(base_url, parameters=parameters, signed=True, post=True)
        
        results = simplejson.loads(response.read())
        results = make_nice.make_it_nice(results)
        return results
Esempio n. 2
0
    def get_photos(self,query=None): 
        """     Retrieves a user's photos based on the Query passed in. *This call requires an access token.*
                Returns a :class:`~troveclient.Objects.Result` object that contains the results of your query
                
                :param query: An instance of :class:~`troveclient.Objects.Query~ object.  If none is passed, assumes page 1 with a count of 50.
        """
        if self._access_token is None:
            raise RequiresAccessTokenError()
        
        parameters = self.__get_default_oauth_params()
        base_url = CONTENT_ROOT_URL + 'photos/'

        if query is not None:
            query_post = simplejson.dumps(query, cls=JSONFactories.encoders.get_encoder_for(query))
            parameters['query'] = query_post
            self.response = self.__make_oauth_request(base_url, parameters, token=self._access_token, signed=True, method="POST")
        else:
            self.response = self.__make_oauth_request(base_url, parameters, token=self._access_token, signed=True, method="GET")
        
        results = simplejson.loads(self.response.read())
        nice_result = make_nice.make_it_nice(results)
        return nice_result