# pprint.pprint(result)

# since there can be only one campaign of this name
# first key is the CAMPAIGN_ID you need
CAMPAIGN_ID = result.keys().pop();

# add contact to 'sample_marketing' campaign
try:
    result = client.add_contact(
        api_key,
        {
            'campaign' : CAMPAIGN_ID,
            'name' : 'Sample Name',
            'email' : '*****@*****.**',
            'cycle_day' : '0',
            'customs' : [
                {
                    'name'       : 'last_purchased_product',
                    'content'    : 'netbook'
                }
            ]
        }
    )
except Exception, e:
    # check for communication and response errors
    # implement handling if needed
    #
    # detailed JSONRPCException and JSONDecodeException
    # are also available in jsonrpc package
    sys.exit(e)