Created
October 22, 2010 18:06
-
-
Save pearcemc/641064 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf import settings #for RECAPTCHA_PRIVATE key | |
def verify_recaptcha(request): | |
import urllib, urllib2, re | |
values = { | |
"privatekey": settings.RECAPTCHA_PRIVATE, | |
"remoteip": request.META['REMOTE_ADDR'], | |
"challenge": request.POST['recaptcha_challenge_field'], | |
"response": request.POST['recaptcha_response_field'], | |
} | |
url = "http://www.google.com/recaptcha/api/verify?%s" % (urllib.urlencode(values)) | |
o = urllib2.urlopen(url) | |
if re.match("^true", o.readline()): return True | |
else: return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment