Skip to content

Instantly share code, notes, and snippets.

@utek
Created August 27, 2013 11:30
Show Gist options
  • Save utek/6352412 to your computer and use it in GitHub Desktop.
Save utek/6352412 to your computer and use it in GitHub Desktop.
Recaptcha helper.
def check_recaptcha(challenge, response, ip, private_key):
import requests
url = "http://www.google.com/recaptcha/api/verify"
data = {
'privatekey': private_key,
'remoteip': ip,
'challenge': challenge,
'response': response,
}
res = requests.post(url, data=data)
response = res.text.splitlines()
if response[0] == u'true':
return (True, response[1])
else:
return (False, response[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment