def dotransform(request, response): client = login() user = client.users(request.fields['affiliation.uid']).get('user', {}) if 'contact' in user and 'facebook' in user['contact']: e = AffiliationFacebook('%s %s' % (user['firstName'], user.get('lastName', ''))) e.profileurl = 'https://facebook.com/%s' % user['contact']['facebook'] e.uid = user['contact']['facebook'] e.network = 'Facebook' response += e return response
def dotransform(request, response): graph = login() try: r = graph.request('search', {'q' : request.value, 'type' : 'user'}) if r['data']: u = r['data'][0] e = AffiliationFacebook(u['name']) e.uid = u['id'] e.profileurl = 'https://www.facebook.com/%s' % u['id'] response += e except GraphAPIError, e: response += UIMessage(str(e))