Ralpharama Archive. The archive is almost 20 years old, this website is no longer maintained.

Home | New Writing | Old Writing | Cooking | Technical | Wine Making | Cocktails

Classic ASP Google recaptcha server-side code

Hits 1651 | Created 2016-02-25 | Modified 2016-02-25

I couldn't find the code for server-side for classic ASP for 2.0, as things changed a bit. Here's a working bit of code.

This is based on the old API, but updated to work for the new version, 2.0.

Assume you set up your FORM correctly, this is on the destination page.

Dim reChallenge : reChallenge = Request.Form("g-recaptcha-response")
Dim VarString
VarString = _
"secret=" & Server.UrlEncode("6Lf3RxYOURSECRETCODEHEREbcLCWpAAvrf8-uGjA2h") & _
"&response=" & Server.UrlEncode(reChallenge) & _
"&remoteip=" & Request.ServerVariables("REMOTE_ADDR")
Dim objXmlHttp
Set objXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
objXmlHttp.open "POST", "https://www.google.com/recaptcha/api/siteverify", False
objXmlHttp.setRequestHeader "Content-Length", len(VarString)
objXmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objXmlHttp.send VarString
Dim ResponseString
ResponseString = split(objXmlHttp.responseText, vblf)
Set objXmlHttp = Nothing
Response.Write ResponseString(0)

Make a Comment


Antispam Code (always a number)

Enter Code Above

Note: All HTML will be removed except for bold and italics. Links will not display. Line breaks are added automatically. Use <pre>...</pre> for code.


This item has the following tags:

Useful? Donate for hosting costs

All content copyright (c) Ralpharama