@@ -0,0 +1,2473 @@
+# -*- coding: utf-8 -*-%0A#%0A# Antes de executar:%0A#%0A# %3E pip install requests%0A#%0A#%0Aimport sys%0Aimport requests%0Afrom requests.packages.urllib3.exceptions import InsecureRequestWarning%0Afrom requests.auth import HTTPBasicAuth%0Aimport xml.etree.ElementTree as ET%0A%0ACONNECTIONS_HOST = 'https://connections.matrix.com'%0ACONNECTIONS_USERNAME = '%3CREPLACE_HERE%3E'%0ACONNECTIONS_PASSWORD = '%3CREPLACE_HERE%3E'%0AQUERY = 'email=smith@matrix.com'%0A# Other options for QUERY%0A# 1) email=%3Cemail_address%3E%0A# 2) uuid=48DD2000-35B2-1E06-A24F-40281701A3F6%0A# 3) uid=F2816859%0A%0ADEBUG=0%0A%0A# Disable Warnings from Untrusted TLs keys%0Arequests.packages.urllib3.disable_warnings(InsecureRequestWarning)%0A%0A# Disable Warnings from Untrusted TLs keys%0Adef doGet(url,headers,auth):%0A    res = requests.get(url=url,headers=headers,auth=auth, verify=False)%0A    if (res.status_code != 200):%0A        print 'requests.get -%3E %25s = %25s%5Cn' %25 (res.url, res)%0A        return None;%0A    #print res.content%0A    return res.content%0A%0Adef parseProfileIfno(content):%0A%0A    root = ET.fromstring(content)%0A    entry = root.find(%22%7Bhttp://www.w3.org/2005/Atom%7Dentry%22)%0A    contributor = entry.find('%7Bhttp://www.w3.org/2005/Atom%7Dcontributor')%0A    name = contributor.find('%7Bhttp://www.w3.org/2005/Atom%7Dname').text%0A    # for namespace snx:userid change to http://www.ibm.com/xmlns/prod/sn%0A    userid = contributor.find('%7Bhttp://www.ibm.com/xmlns/prod/sn%7Duserid').text%0A    email = contributor.find('%7Bhttp://www.w3.org/2005/Atom%7Demail').text%0A    userState = contributor.find('%7Bhttp://www.ibm.com/xmlns/prod/sn%7DuserState').text%0A%0A    profile = %7B%0A    'name': name,%0A    'userid': userid,%0A    'email': email,%0A    'userState': userState%0A    %7D%0A    #print profile%0A    return profile%0A%0Adef getProfileInfo(query):%0A    url = CONNECTIONS_HOST + '/profiles/atom/profile.do?' + query%0A    print url + '%5Cn'%0A    headers = %7B 'Content-Type': 'application/atom+xml;charset=UTF-8'%7D%0A    auth=None%0A%0A    feed = doGet(url=url,headers=headers,auth=auth)%0A    if (feed is None):%0A        return None%0A    return parseProfileIfno(feed)%0A%0A#################### Main Module ###################%0Aprint 'Connecting to IBM Connections...%5Cn'%0Aif (DEBUG == 1):%0A    print sys.stdout.encoding + '%5Cn%5Cn'%0A%0Aprofile = getProfileInfo(QUERY)%0A%0Aif (profile is None):%0A    print 'Cannot get Profile Information.'%0A    sys.exit(1)%0A%0Aprint 'Profile Information:%5Cn'%0Aprint profile%5B'name'%5D%0Aprint ' %7C--%3E userid: ' + profile%5B'userid'%5D%0Aprint ' %7C--%3E email: ' + profile%5B'email'%5D%0Aprint ' %7C--%3E userState: ' + profile%5B'userState'%5D%0A

Create GetUserInformationOnProfiles.py