Using Google reCAPTCHA version 2.0 using classic asp

Google reCAPTCHA version 2 is totally different than the first version. Here's some code that allows you to use the new "I'm not a robot" version of recaptcha using classic asp.

CODE:

<html>

<body>

<%

Dim action, reresponse, recaptchagood

action = request.form("Action")

If action="Go" then

reresponse= Request.form("g-recaptcha-response")

Dim VarString

VarString = _

"?secret=yoursecretkey&amp;" & _

"&response=" & reresponse & _

"&amp;&remoteip=" & Request.ServerVariables("REMOTE_ADDR")

Dim url

url="https://www.google.com/recaptcha/api/siteverify" & VarString

Dim objXmlHttp

Set objXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")

objXmlHttp.open "POST", url, False

objXmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

objXmlHttp.send

Dim ResponseString

ResponseString = objXmlHttp.responseText

Set objXmlHttp = Nothing

If instr(ResponseString, "success" & chr(34) &": true")>0 then

recaptchagood="Yes"

end if

End if

%>

<script src="https://www.google.com/recaptcha/api.js" async defer></script>

<form action="recaptchatest.asp" method="POST">

<div class="g-recaptcha" data-sitekey="yoursecretkey"></div>

<br/>

<input type="hidden" name="Action" value="Go">

<input type="submit" value="Submit">

</form>

</body>

<html>