Tag Archives: reCAPTCHA

Recaptcha V2 under classic ASP

Here’s a quick primer on upgrading your Classic ASP site Recaptcha V1 to V2.

First, go to Google Recaptcha online and generate yourself a v2 pair of keys for your site’s domain.


On the page with the “FORM” on it on which you want to display the Recaptcha V2.

Add to the HEADER (inside the HEAD TAGS):

<script src='https://www.google.com/recaptcha/api.js'></script>


Replace the existing code which renders your v1 recaptcha with this line:

<div class="g-recaptcha" data-sitekey="put your google public v2 key here" ></div>


on your FORM SUBMIT page (where the v2 form gets submitted to):

Inside ASP tags, place this line:

Response.LCID = 1033 ' USA LCID

It is a required element for the JSON Parser.

Inside the HEAD:

<!--#include file="jsonObject.class.asp" -->


you can get this file from my site HERE

now the processing code to handle the Recaptcha JSON response:


If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
 Dim recaptcha_secret, sendstring, objXML
 recaptcha_secret = "your secret key goes here"

 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

 set jsonObj = new JSONobject
 set jsonArr = new jsonArray

 jsonString = objXML.responseText
 set outputObj = jsonObj.parse(jsonString)  
 if jsonObj.value("success") then
  Global_Msg="Captcha GOOD!"
  Global_Msg="Invalid Recaptcha Response."
 end if
 Set objXML = Nothing
End If

if Global_Msg<>"Captcha GOOD!" then
invalid RECAPTCHA response.  Hit back and try again.

end if


For your convenience, here is all the code inside one ZIP file.


Let me know if this helped you!



reCAPTCHA in SSL – Changes coming – update your code

Important news for developers using reCAPTCHA on your sites.

If you are currently using http://api.recaptcha.net/challenge?k=XXXX and you need to implement reCAPTCHA on an SSL protected page — you need to switch the links to https://www.google.com/recaptcha/api/challenge?k=XXXYYYZZZ.

Per Google, this change went into effect April 2011.


Change from this (OLD) To this (NEW)
http://api.recaptcha.net/challenge?k=XXXX https://www.google.com/recaptcha/api/challenge?k=XXXYYYZZZ
http://api-verify.recaptcha.net/verify http://www.google.com/recaptcha/api/verify
http://api.recaptcha.net/noscript?k= http://www.google.com/recaptcha/api/noscript?k=


For more information, read this page