如何在ASP Classic中实现Google Recaptcha 2.0?

Ed *_*ias 3 asp-classic

我需要帮助来实现Google Recaptcha 2.0的答案.

我已经尝试了几种方法来恢复发送表单后的响应,但不是consigui得到答案真.

按照我正在尝试的示例:

recaptcha_secret = "example45454sasa"

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()

if instr(objXML.responseText,"true") then
    response.write "yes"
else
    response.write "no"
end if
Run Code Online (Sandbox Code Playgroud)

第二个exmeplae我使用aspJSON1.17.asp库:

recaptcha_secret = "example45454sasa"

Set oJSON = New aspJSON

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

'Load JSON string
oJSON.loadJSON("" & jsonstring & "")

'Get single value
Response.Write oJSON.data("success") & ""
Run Code Online (Sandbox Code Playgroud)

上面的两个例子返回False或No.

如何实现检查Recaptcha是否已标记的方法?

*reCaptcha Documentatiom

谢谢你的关注!

Zam*_*Zam 14

我不知道你如何发送请求.

无论如何,下面是我的网站密钥测试网站的工作示例.当然,你应该提供自己的"密钥"和"data-sitekey"

现场样本:http://1click.lv/googlecaptcha.asp

文件名:GoogleCaptcha.asp

<%@LANGUAGE=VBSCRIPT%>
<%
    Option Explicit
%>
<html>
    <head>
        <script src="https://www.google.com/recaptcha/api.js" async defer></script>
    </head>

    <body>
        <h4>http://stackoverflow.com/questions/30711884/how-to-implement-google-recaptcha-2-0-in-asp-classic/30735079</h4>
<%
    If Request.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">
            <!-- Site key -->
            <div class="g-recaptcha" data-sitekey="6LfUUwgTAAAAAAQZPb6j22A2a2tZoAUygdmqpgdv"></div>
            <br />
            <input type="submit" value="Try">
        </form>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)