Exemple #1
0
 def multi(self, queries, **params):
     
     """
     Execute multiple FQL queries (using `fql.multiquery`).
     
     Example:
     
         >>> q = FQL('access_token')
         >>> result = q.multi(dict(query1="SELECT...", query2="SELECT..."))
         
         >>> result[0].name
         'query1'
         >>> result[0].fql_result_set
         [...]
         
         >>> result[1].name
         'query2'
         >>> result[1].fql_result_set
         [...]
     
     """
     
     url = add_path(self.ENDPOINT, 'fql.multiquery')
     params.update(queries=json.dumps(queries),
                   access_token=self.access_token, format='json')
     url = update_query_params(url, params)
     
     return self.fetch_json(url)
Exemple #2
0
    def multi(self, queries, **params):
        """
        Execute multiple FQL queries (using `fql.multiquery`).
        
        Example:
        
            >>> q = FQL('access_token')
            >>> result = q.multi(dict(query1="SELECT...", query2="SELECT..."))
            
            >>> result[0].name
            'query1'
            >>> result[0].fql_result_set
            [...]
            
            >>> result[1].name
            'query2'
            >>> result[1].fql_result_set
            [...]
        
        """

        url = add_path(self.ENDPOINT, 'fql.multiquery')
        params.update(queries=json.dumps(queries),
                      access_token=self.access_token,
                      format='json')
        url = update_query_params(url, params)

        return self.fetch_json(url)
Exemple #3
0
 def __call__(self, query, **params):
     
     """
     Execute a single FQL query (using `fql.query`).
     
     Example:
     
         >>> q = FQL('access_token')
         >>> result = q("SELECT post_id FROM stream WHERE source_id = ...")
         >>> result
         [Bunch(post_id='XXXYYYZZZ'), ...]
         
         >>> result[0]
         Bunch(post_id='XXXYYYZZZ')
         
         >>> result[0].post_id
         'XXXYYYZZZ'
     
     """
     
     url = add_path(self.ENDPOINT, 'fql.query')
     params.update(query=query, access_token=self.access_token,
                   format='json')
     url = update_query_params(url, params)
     
     return self.fetch_json(url)
Exemple #4
0
    def __call__(self, query, **params):
        """
        Execute a single FQL query (using `fql.query`).
        
        Example:
        
            >>> q = FQL('access_token')
            >>> result = q("SELECT post_id FROM stream WHERE source_id = ...")
            >>> result
            [Bunch(post_id='XXXYYYZZZ'), ...]
            
            >>> result[0]
            Bunch(post_id='XXXYYYZZZ')
            
            >>> result[0].post_id
            'XXXYYYZZZ'
        
        """

        url = add_path(self.ENDPOINT, 'fql.query')
        params.update(query=query,
                      access_token=self.access_token,
                      format='json')
        url = update_query_params(url, params)

        return self.fetch_json(url)
Exemple #5
0
    def call_fb(self, **params):
        """Read the current URL, and JSON-decode the results."""

        if self.access_token:
            params['access_token'] = self.access_token
        url = update_query_params(self.url, params)
        data = json.loads(self.fetch(url,
                                     timeout=self.timeout,
                                     retries=self.retries,
                                     urllib2=self.urllib2,
                                     httplib=self.httplib))
        return self.process_response(data, params)
Exemple #6
0
    def call_fb(self, **params):
        """Read the current URL, and JSON-decode the results."""

        if self.access_token:
            params['access_token'] = self.access_token
        url = update_query_params(self.url, params)
        data = json.loads(
            self.fetch(url,
                       timeout=self.timeout,
                       retries=self.retries,
                       urllib2=self.urllib2,
                       httplib=self.httplib))
        return self.process_response(data, params)
Exemple #7
0
def add_query_params(url, params):
    """use the _update_query_params function to set a new query
    string for the url based on params.
    """
    return update_query_params(url, params, update=False)
Exemple #8
0
 def with_url_params(self, param, val):
     """
         this used to overload the bitwise OR op
     """
     return self.copy(url=update_query_params(self.url, (param, val)))
Exemple #9
0
def add_query_params(url, params):
    """use the _update_query_params function to set a new query
    string for the url based on params.
    """
    return update_query_params(url, params, update=False)
Exemple #10
0
 def with_url_params(self, param, val):
     """
         this used to overload the bitwise OR op
     """
     return self.copy(url=update_query_params(self.url, (param, val)))