def api_call(target_version, target_api_url, session, debug=False, authenticate=True):
 resource_url = (('/api/' + target_version) + target_api_url)
 try:
  if (authenticate and session.REQUEST_TOKEN and session.ACCESS_TOKEN):
   client = TestOAuthClient(session.SERVER_URL, CONSUMER_KEY, CONSUMER_SECRET)
   response = client.access_resource(resource_url, session.ACCESS_TOKEN)
  else:
   response = requests.get((session.SERVER_URL + resource_url)).content
  json_object = json.loads(response)
 except Exception as e:
  print e, ('for target: %(target)s ' % {'target': target_api_url})
  return {}
 if debug:
  print json_object
 return json_object

def api_call ( target_version , target_api_url , session , debug = False , authenticate = True ) : resource_url = ( ( '/api/' + target_version ) + target_api_url ) try : if ( authenticate and session . REQUEST_TOKEN and session . ACCESS_TOKEN ) : client = TestOAuthClient ( session . SERVER_URL , CONSUMER_KEY , CONSUMER_SECRET ) response = client . access_resource ( resource_url , session . ACCESS_TOKEN ) else : response = requests . get ( ( session . SERVER_URL + resource_url ) ) . content json_object = json . loads ( response ) except Exception as e : print e , ( 'for target: %(target)s ' % { 'target' : target_api_url } ) return { } if debug : print json_object return json_object
generic api call function .