import urllib2, urllib
-API_SSL_SERVER="https://api-secure.recaptcha.net"
-API_SERVER="http://api.recaptcha.net"
-VERIFY_SERVER="api-verify.recaptcha.net"
+API_SSL_SERVER="https://www.google.com/recaptcha/api"
+API_SERVER="http://www.google.com/recaptcha/api"
+VERIFY_SERVER="www.google.com"
class RecaptchaResponse(object):
def __init__(self, is_valid, error_code=None):
return s
params = urllib.urlencode ({
- 'privatekey': encode_if_necessary(private_key),
- 'remoteip' : encode_if_necessary(remoteip),
- 'challenge': encode_if_necessary(recaptcha_challenge_field),
- 'response' : encode_if_necessary(recaptcha_response_field),
- })
+ 'privatekey': encode_if_necessary(private_key),
+ 'remoteip' : encode_if_necessary(remoteip),
+ 'challenge': encode_if_necessary(recaptcha_challenge_field),
+ 'response' : encode_if_necessary(recaptcha_response_field),
+ })
request = urllib2.Request (
- url = "http://%s/verify" % VERIFY_SERVER,
+ url = "http://%s/recaptcha/api/verify" % VERIFY_SERVER,
data = params,
headers = {
"Content-type": "application/x-www-form-urlencoded",
"User-agent": "reCAPTCHA Python"
- }
- )
+ }
+ )
httpresp = urllib2.urlopen (request)
if (return_code == "true"):
return RecaptchaResponse (is_valid=True)
else:
- return RecaptchaResponse (is_valid=False, error_code = return_values [1])
-
-
+ return RecaptchaResponse (is_valid=False, error_code = return_values [1])
\ No newline at end of file