#! /usr/bin/python2.6

import json, simplejson, datetime, time, urllib2

def get_content():
	try:
		url = "http://en.lipsum.com/feed/json?amount=1"
		file = urllib2.urlopen(url)
		content = file.read()
		if content is not None:  
			json = simplejson.loads(content)
			out = json['feed']['lipsum']
	except: 
		out = 'Error content'
	return out	

def main(CONTENT):
    try:
        url = "http://%s.api.konkr.com/isspam?author_ip='%s'&content='%s'" % (API_KONKR_KEY, AUTHOR, CONTENT)
        file = urllib2.urlopen(url)
        data = file.read()
        if data:
			json = simplejson.loads(data)              
			msg = json['success']
    except: 
        msg = 'Error detect spam'

    print msg

if __name__ == "__main__":
	API_KONKR_KEY = 'your_key'
	AUTHOR = '127.0.0.1'
	SPAM = 'Sex viagra porn Sarkozy clocking and enlarge your very little penis'
	HAM = get_content()

	print 'Detect ham'
	main(HAM)  
	print 'Detect spam'
	main(SPAM)