Exemplo n.º 1
0
    def get_network_updates(self, access_token, **kwargs):
        """Get network updates for the current user.  Valid keyword arguments are
        "count", "start", "type", "before", and "after".  "Count" and "start" are for the number
        of updates to be returned.  "Type" specifies what type of update you are querying.
        "Before" and "after" set the time interval for the query.  Valid argument types are
        an integer representing UTC with millisecond precision or a Python datetime object.
        """
        if 'type' in kwargs.keys():
            assert type(kwargs['type']) == type(
                list()), 'Keyword argument "type" must be of type "list"'
            [self.check_network_code(c) for c in kwargs['type']]

        if 'before' in kwargs.keys():
            kwargs['before'] = self.dt_obj_to_string(
                kwargs['before']) if kwargs['before'] else None
        if 'after' in kwargs.keys():
            kwargs['after'] = self.dt_obj_to_string(
                kwargs['after']) if kwargs['after'] else None

        user_token, url = self.prepare_request(access_token,
                                               self.api_network_update_url,
                                               kwargs)
        client = oauth.Client(self.consumer, user_token)
        resp, content = client.request(url, 'GET')
        content = self.clean_dates(content)
        return LinkedInXMLParser(content).results
Exemplo n.º 2
0
    def get_user_profile(self,
                         access_token,
                         selectors=None,
                         headers=None,
                         **kwargs):
        """
        Get a user profile.  If keyword argument "id" is not supplied, this
        returns the current user's profile, else it will return the profile of
        the user whose id is specificed.  The "selectors" keyword argument takes
        a list of LinkedIn compatible field selectors.
        """

        assert type(selectors) == type(
            []), '"Keyword argument "selectors" must be of type "list"'
        user_token, url = self.prepare_request(access_token,
                                               self.api_profile_url, kwargs)
        client = oauth.Client(self.consumer, user_token)

        if headers is None:
            headers = {}

        if not selectors:
            resp, content = client.request(self.api_profile_url,
                                           'GET',
                                           headers=headers)
        else:
            url = self.prepare_field_selectors(selectors, url)
            resp, content = client.request(url, 'GET', headers=headers)

        return LinkedInXMLParser(content).results
Exemplo n.º 3
0
 def get_comment_feed(self, access_token, network_key):
     """
     Get a comment feed for a particular network update.  Requires the update key
     for the network update as returned by the API.
     """
     url = re.sub(r'\{NETWORK UPDATE KEY\}', network_key, self.api_comment_feed_url)
     user_token, url = self.prepare_request(access_token, url)
     client = oauth.Client(self.consumer, user_token)
     resp, content = client.request(url, 'GET')
     content = self.clean_dates(content)
     return LinkedInXMLParser(content).results
Exemplo n.º 4
0
 def search(self, access_token, data):
     """
     Use the LinkedIn Search API to find users.  The criteria for your search
     should be passed as the 2nd positional argument as a dictionary of key-
     value pairs corresponding to the paramters allowed by the API.  Formatting
     of arguments will be done for you (i.e. lists of keywords will be joined
     with "+")
     """
     srch = LinkedInSearchAPI(data, access_token)
     client = oauth.Client(self.consumer, srch.user_token)
     rest, content = client.request(srch.generated_url, method='GET')
     return LinkedInXMLParser(content).results
Exemplo n.º 5
0
 def get_user_connections(self, access_token, selectors=None, **kwargs):
     """
     Get the connections of the current user.  Valid keyword arguments are
     "count" and "start" for the number of profiles you wish returned.  Types
     are automatically converted from integer to string for URL formatting
     if necessary.
     """
     if selectors:
         url = self.prepare_field_selectors(selectors, self.api_profile_connections_url)
     user_token, url = self.prepare_request(access_token, url, kwargs)
     client = oauth.Client(self.consumer, user_token)
     resp, content = client.request(url, 'GET')
     self.status_check(resp, content)
     content = self.clean_dates(content)
     return LinkedInXMLParser(content).results
Exemplo n.º 6
0
 def get_user_connections(self,
                          access_token,
                          selectors=None,
                          params=None,
                          headers=None):
     """
     Get the connections of the current user.  Valid keyword arguments are
     "count" and "start" for the number of profiles you wish returned.  Types
     are automatically converted from integer to string for URL formatting
     if necessary.
     """
     if selectors:
         url = self.prepare_field_selectors(
             selectors, self.api_profile_connections_url)
     if params is None:
         params = {}
     if headers is None:
         headers = {}
     user_token, url = self.prepare_request(access_token, url, params)
     client = oauth.Client(self.consumer, user_token)
     resp, content = client.request(url, 'GET', headers=headers)
     return LinkedInXMLParser(content).results