Show me the code! – By Davanum Srinivas

January 4, 2012

Follow a user in Lotus Connections 3.0

Filed under: Uncategorized — Tags: , — Davanum Srinivas @ 3:35 pm

One main feature in Lotus Connections 3.0 is the asymmetric follow of someone (like twitter). The API documentation is here. Since sample code is always better here’s a HTTP GET python snippet to lookup the userid, given an email and then a quick HTTP POST to follow that user.

import sys,urllib,urllib2,traceback,base64
from xml.dom import minidom

xml_data_header = """
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="">
   <category term="resource-follow" scheme=""></category>
   <category term="profiles" scheme=""></category>
   <category term="profile" scheme=""></category>
   <category term="
xml_data_footer = """
" scheme=""></category>

if len(sys.argv) != 4: 
        print 'Usage: follow <userid> <password> <email-of-user-to-follow>' 

base64string = base64.encodestring('%s:%s' % (sys.argv[1], sys.argv[2]))[:-1]

def getUuidForUser(email):
	uri = "" % email
	req = urllib2.Request(uri)
	req.add_header('Authorization', "Basic %s" % base64string)
	dom = minidom.parse(urllib2.urlopen(req))
	element = dom.getElementsByTagNameNS('', 'userid')[0]

def followUser(uuid):
	uri = ''
	query_string_values = {'source': 'profiles', 'type'  : 'profile'}
	payload = '%s%s%s' % (xml_data_header, uuid, xml_data_footer)

	try :
		if query_string_values:
		    uri = ''.join([uri, '?', urllib.urlencode(query_string_values)])
		req = urllib2.Request(uri, data=payload)
		req.add_header('Authorization', "Basic %s" % base64string)
		response = urllib2.urlopen(req)
	except urllib2.HTTPError, error:

print followUser(getUuidForUser(sys.argv[3]))

Blog at