{"id":574,"date":"2018-05-07T11:22:36","date_gmt":"2018-05-07T15:22:36","guid":{"rendered":"http:\/\/www.amixa.com\/blog\/?p=574"},"modified":"2018-05-07T11:22:36","modified_gmt":"2018-05-07T15:22:36","slug":"recaptcha-v2-under-classic-asp","status":"publish","type":"post","link":"https:\/\/www.amixa.com\/blog\/2018\/05\/07\/recaptcha-v2-under-classic-asp\/","title":{"rendered":"Recaptcha V2 under classic ASP"},"content":{"rendered":"<p>Here&#8217;s a quick primer on upgrading your Classic ASP site Recaptcha V1 to V2.<\/p>\n<p>First, go to Google Recaptcha online and generate yourself a v2 pair of keys for your site&#8217;s domain.<\/p>\n<p>Next:<\/p>\n<p>On the page with the &#8220;FORM&#8221; on it on which you want to display the Recaptcha V2.<\/p>\n<p><strong>Add to the HEADER (inside the HEAD TAGS):<\/strong><\/p>\n<pre>&lt;script src='https:\/\/www.google.com\/recaptcha\/api.js'&gt;&lt;\/script&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Replace the existing code which renders your v1 recaptcha with this line:<\/strong><\/p>\n<pre>&lt;div class=\"g-recaptcha\" data-sitekey=\"put your google public v2 key here\" &gt;&lt;\/div&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>on your FORM SUBMIT page (where the v2 form gets submitted to):<\/strong><\/p>\n<p><strong>Inside ASP tags, place this line:<\/strong><\/p>\n<pre>Response.LCID = 1033 ' USA LCID<\/pre>\n<p>It is a required element for the JSON Parser.<\/p>\n<p><strong>Inside the HEAD:<\/strong><\/p>\n<pre>&lt;!--#include file=\"jsonObject.class.asp\" --&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p>you can get this file from my site <a href=\"http:\/\/www.amixa.com\/blog\/wp-content\/uploads\/2018\/05\/jsonObject.zip\">HERE<\/a><\/p>\n<p>now the processing code to handle the Recaptcha JSON response:<\/p>\n<p>&nbsp;<\/p>\n<pre>If Request.ServerVariables(\"REQUEST_METHOD\") = \"POST\" Then\r\n\u00a0Dim recaptcha_secret, sendstring, objXML\r\n\u00a0\r\n\u00a0recaptcha_secret = \"your secret key goes here\"\r\n\r\n\u00a0sendstring = \"https:\/\/www.google.com\/recaptcha\/api\/siteverify?secret=\" &amp; recaptcha_secret &amp; \"&amp;response=\" &amp; Request.form(\"g-recaptcha-response\")\r\n\r\n\u00a0Set objXML = Server.CreateObject(\"MSXML2.ServerXMLHTTP\")\r\n\u00a0objXML.Open \"GET\", sendstring, False\r\n\r\n\u00a0objXML.Send\r\n\u00a0\r\n\u00a0set jsonObj = new JSONobject\r\n\u00a0set jsonArr = new jsonArray\r\n\r\n\r\n\u00a0jsonString = objXML.responseText\r\n\u00a0\r\n\u00a0set outputObj = jsonObj.parse(jsonString)\u00a0\u00a0\r\n\u00a0\r\n\u00a0\r\n\u00a0if jsonObj.value(\"success\") then\r\n\u00a0\u00a0Global_Msg=\"Captcha GOOD!\"\r\n\u00a0else\r\n\u00a0\u00a0Global_Msg=\"Invalid Recaptcha Response.\"\r\n\u00a0end if\r\n\u00a0\r\n\u00a0Set objXML = Nothing\r\nEnd If\r\n\r\nif Global_Msg&lt;&gt;\"Captcha GOOD!\" then\r\n%&gt;\r\ninvalid RECAPTCHA response.\u00a0 Hit back and try again.\r\n&lt;%\r\nresponse.end\r\n\r\nend if<\/pre>\n<p>&nbsp;<\/p>\n<p>For your convenience, <a href=\"http:\/\/www.amixa.com\/blog\/wp-content\/uploads\/2018\/05\/recaptcha-v2.zip\">here is all the code inside one ZIP file<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<p>Let me know if this helped you!<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;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&#8217;s domain. Next: On the page with the &#8220;FORM&#8221; on it on which you want to display the Recaptcha V2. Add to the HEADER (inside the HEAD TAGS): &lt;script src=&#8217;https:\/\/www.google.com\/recaptcha\/api.js&#8217;&gt;&lt;\/script&gt;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33,1],"tags":[84,103,49],"class_list":["post-574","post","type-post","status-publish","format-standard","hentry","category-classic-asp","category-random-bits","tag-asp","tag-classic-asp","tag-recaptcha"],"_links":{"self":[{"href":"https:\/\/www.amixa.com\/blog\/wp-json\/wp\/v2\/posts\/574","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.amixa.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.amixa.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.amixa.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.amixa.com\/blog\/wp-json\/wp\/v2\/comments?post=574"}],"version-history":[{"count":1,"href":"https:\/\/www.amixa.com\/blog\/wp-json\/wp\/v2\/posts\/574\/revisions"}],"predecessor-version":[{"id":577,"href":"https:\/\/www.amixa.com\/blog\/wp-json\/wp\/v2\/posts\/574\/revisions\/577"}],"wp:attachment":[{"href":"https:\/\/www.amixa.com\/blog\/wp-json\/wp\/v2\/media?parent=574"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.amixa.com\/blog\/wp-json\/wp\/v2\/categories?post=574"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.amixa.com\/blog\/wp-json\/wp\/v2\/tags?post=574"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}