Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Minor fixes for the linkedin search API #1

Closed
wants to merge 2 commits into from

2 participants

@pydanny

This fix corrects the Search API and adds in UnavailableAPIService Exception for when linkedin's API is down.

@mrgaaron
Owner

Read the fixes, looks good to me. I'll be able to pull these changes in and merge them hopefully later this evening or tomorrow.

@pydanny

Is there any point to keeping this pull request open?

@pydanny pydanny closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 4 deletions.
  1. +1 −3 liclient/__init__.py
  2. +9 −1 liclient/parsers/lixml.py
View
4 liclient/__init__.py
@@ -230,7 +230,6 @@ def prepare_request(self, access_token, url, kws=[]):
else:
prep_url = self.append_sequential_arg(k, kws[k], prep_url)
prep_url = re.sub('&&', '&', prep_url)
- print prep_url
return user_token, prep_url
def append_id_args(self, ids, prep_url):
@@ -269,7 +268,6 @@ def prepare_field_selectors(self, selectors, url):
selector_string = selector_string.strip(',')
selector_string += ')'
prep_url += selector_string
- print prep_url
return prep_url
def check_network_code(self, code):
@@ -363,7 +361,7 @@ def invitation_factory(self, recipient, subject, body, **kwargs):
class LinkedInSearchAPI(LinkedInAPI):
def __init__(self, params, access_token):
- self.api_search_url = 'http://api.linkedin.com/v1/people/'
+ self.api_search_url = 'http://api.linkedin.com/v1/people'
self.routing = {
'keywords': self.keywords,
'name': self.name,
View
10 liclient/parsers/lixml.py
@@ -2,6 +2,10 @@
import mappers
import re
+class UnavailableAPIService(Exception):
+ pass
+
+
class LinkedInXMLParser(object):
def __init__(self, content):
self.routing = {
@@ -17,7 +21,11 @@ def __init__(self, content):
}
self.tree = etree.fromstring(content)
self.root = self.tree.tag
- self.results = self.__forward_tree(self.tree, self.root)
+ try:
+ self.results = self.__forward_tree(self.tree, self.root)
+ except KeyError as e:
+ raise UnavailableAPIService(e)
+
def __forward_tree(self, tree, root):
results = self.routing[root](tree)
Something went wrong with that request. Please try again.