def get_contacts(self, credentials):
     from oauth_access.access import OAuthAccess
     yahoo_token = credentials["yahoo_token"]
     access = OAuthAccess("yahoo")
     guid = access.make_api_call(
         "json",
         "http://social.yahooapis.com/v1/me/guid?format=json",
         yahoo_token
     )["guid"]["value"]
     address_book = access.make_api_call(
         "json",
         "http://social.yahooapis.com/v1/user/%s/contacts?format=json&count=max&view=tinyusercard" % guid,
         yahoo_token,
     )
     for contact in address_book["contacts"]["contact"]:
         # e-mail (if not found skip contact)
         try:
             email = self.get_field_value(contact, "email")
         except KeyError:
             continue
         # name (first and last comes together)
         try:
             name = self.get_field_value(contact, "name")
         except KeyError:
             name = ""
         if name:
             first_name = name["givenName"]
             last_name = name["familyName"]
             if first_name and last_name:
                 name = "%s %s" % (first_name, last_name)
             elif first_name:
                 name = first_name
             elif last_name:
                 name = last_name
             else:
                 name = ""
         yield {
             "email": email,
             "name": name,
         }
Esempio n. 2
0
 def get_contacts(self, credentials):
     from oauth_access.access import OAuthAccess
     yahoo_token = credentials["yahoo_token"]
     access = OAuthAccess("yahoo")
     guid = access.make_api_call(
         "json", "http://social.yahooapis.com/v1/me/guid?format=json",
         yahoo_token)["guid"]["value"]
     address_book = access.make_api_call(
         "json",
         "http://social.yahooapis.com/v1/user/%s/contacts?format=json&count=max&view=tinyusercard"
         % guid,
         yahoo_token,
     )
     for contact in address_book["contacts"]["contact"]:
         # e-mail (if not found skip contact)
         try:
             email = self.get_field_value(contact, "email")
         except KeyError:
             continue
         # name (first and last comes together)
         try:
             name = self.get_field_value(contact, "name")
         except KeyError:
             name = ""
         if name:
             first_name = name["givenName"]
             last_name = name["familyName"]
             if first_name and last_name:
                 name = "%s %s" % (first_name, last_name)
             elif first_name:
                 name = first_name
             elif last_name:
                 name = last_name
             else:
                 name = ""
         yield {
             "email": email,
             "name": name,
         }
Esempio n. 3
0
 def get_contacts(self, credentials):
     from oauth_access.access import OAuthAccess
     linkedin_token = credentials["linkedin_token"]
     access = OAuthAccess("linkedin")
     tree = access.make_api_call(
         "xml",
         "http://api.linkedin.com/v1/people/~/connections:(first-name,last-name)",
         linkedin_token,
     )
     persons = list(tree.iter("person"))
     for person in persons:
         name = ''
         first_name = person.find('first-name')
         if first_name is not None and first_name.text:
             name = first_name.text
         last_name = person.find('last-name')
         if last_name is not None and last_name.text:
             if name:
                 name += ' '
             name += last_name.text
         yield {
             "email": "",
             "name": name,
         }
Esempio n. 4
0
 def get_contacts(self, credentials):
     from oauth_access.access import OAuthAccess
     linkedin_token = credentials["linkedin_token"]
     access = OAuthAccess("linkedin")
     tree = access.make_api_call(
         "xml",
         "http://api.linkedin.com/v1/people/~/connections:(first-name,last-name)",
         linkedin_token,
     )
     persons = list(tree.iter("person"))
     for person in persons:
         name = ''
         first_name = person.find('first-name')
         if first_name is not None and first_name.text:
             name = first_name.text
         last_name = person.find('last-name')
         if last_name is not None and last_name.text:
             if name:
                 name += ' '
             name += last_name.text
         yield {
             "email": "",
             "name": name,
         }