Risolto reCAPTCHA v2 per ASP

  • Creatore Discussione Creatore Discussione Paolo69
  • Data di inizio Data di inizio
Da utilizzare quando la questione possa nel Thread è stata risolta con successo

Paolo69

Moderatore
Membro dello Staff
MOD
18 Feb 2010
555
13
18
Italy
www.caprioli.info
Salve, condivido con la community di MRW questa personale esperienza, visto che non ho trovato nulla di pronto e funzionante.

Per integrare un CAPTCHA di Google (noto come "reCAPTCHA") sul tuo sito, devi principalmente registrare il tuo sito sul sito reCAPTCHA-Enterprise, ottenere così le varie chiavi pubblica/privata da inserire negli appositi frammenti di codice che segue.

PS: non posso pubblicare i link, li troverete facilmente sui motori di ricerca.

Pagina esempio (ovviamente ci sono le tre chiavi da inserire tra le ""):

Codice:
<%@ LANGUAGE="VBScript" %>
<%

Dim objHTTP
Set objHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
objHTTP.Open "POST", "https://recaptcha.net/recaptcha/api/siteverify", False
objHTTP.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objHTTP.Send "secret=" & Server.URLEncode("___chiave_privata____") & "&response=" & Server.URLEncode(Request.Form("g-recaptcha-response"))

Dim strResponse
strResponse = objHTTP.ResponseText

If InStr(strResponse, """success"": true") Then
  'reCAPTCHA Enterprise verification was successful
  'process form data here
  %>ok<%
Else
  'reCAPTCHA Enterprise verification failed
  'display error message
  %>errore<%
End If

%>
<html>
<head>
<title>Recaptcha - Classic ASP</title>
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<meta name="description" content="Classic ASP Recaptcha examples">
<meta name="keywords" content="recaptcha, classic, asp, example, examples">
<meta name="rating" content="general">
<meta name="robots" content="index,follow">
</head>

<body>
<script src="https://www.google.com/recaptcha/enterprise.js?render=__chiave_pubblica_____"></script>
<script>
grecaptcha.enterprise.ready(function() {
    grecaptcha.enterprise.execute('___chiave_pubblica_enterprise__', {action: 'login'}).then(function(token) {
       ...
    });
});
</script>

<form action="capcha.asp?action=ok" method="post">
<div class="g-recaptcha" data-sitekey="______chiave_pubblica_sito_________"></div>
<script src='https://recaptcha.net/recaptcha/api.js'></script>
<input type="submit" name="invio"/>
</form>
</body>
</html>

Buona fortuna :)
 

Discussioni simili