How to implement google reCAPTCHA using classic asp

2

Hello,

I can not deploy recaptcha using classic ASP .

The tips of the google site are confusing me and I can not implement. Could someone pass me a "be a ba" with the steps? The keys I already have!

    
asked by anonymous 15.12.2015 / 12:53

2 answers

1

If you already have the key, you should replace it in the code below:

File name: GoogleCaptcha.asp

<%@LANGUAGE=VBSCRIPT%>
<%
    Option Explicit
%>
<html>
    <head>
        <script src="https://www.google.com/recaptcha/api.js"asyncdefer></script></head><body><%IfRequest.ServerVariables("REQUEST_METHOD") = "POST" Then
        Dim recaptcha_secret, sendstring, objXML
        ' Secret key
        recaptcha_secret = "6LfUUwgTAAAAAMQy5tz9u1BMSnCQV1CVh5tuBcEF"

        sendstring = "https://www.google.com/recaptcha/api/siteverify?secret=" & recaptcha_secret & "&response=" & Request.form("g-recaptcha-response")

        Set objXML = Server.CreateObject("MSXML2.ServerXMLHTTP")
        objXML.Open "GET", sendstring, False

        objXML.Send

        Response.write "<h3>Response: " & objXML.responseText & "</h3>"

        Set objXML = Nothing
    End If
%>

        <form method="post" action="GoogleCaptcha.asp">
            <!-- ///////////// SUA CHAVE ABAIXO ///////////// -->
            <div class="g-recaptcha" data-sitekey="---CHAVE--"></div>
            <br />
            <input type="submit" value="Try">
        </form>
    </body>
</html>

Running: link

Source: SOen and This article

    
15.12.2015 / 17:47
0

I went behind and got it done. You just needed to make a validation to redirect according to google's response:

I did the following:

Soon after the script: objXML.Send. Type the text below:

'Routine created by geovan mello, to redirect according to your will         Dim SearchString, SearchChar, MyPos         SearchString = objXML.responseText 'String where to search         SearchChar="false" 'Search for "false"         MyPos = Instr (4, SearchString, SearchChar, 1)

     if MinhaPos = "16" then
     response.Redirect("arquivo_de_erro.asp")
     end if
    Set objXML = Nothing
    
15.12.2015 / 20:27