Advertisement
sollinger04

Nocaptcha Processing with CFScript

Aug 15th, 2015
593
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <cfscript>
  2.     //Validate captcha
  3.     if(structkeyExists(form,'g-recaptcha-response')){
  4.         //Create new HTTP object
  5.         httpService = new http();
  6.         httpService.setMethod("GET");
  7.         httpService.setUrl( "https://www.google.com/recaptcha/api/siteverify" );
  8.         //Set HTTP parameters
  9.         httpService.addParam(type="formfield", name="secret", value="YOUR SECRET KEY GOES HERE");
  10.         httpService.addParam(type="formfield", name="response", value="#form['g-recaptcha-response']#");
  11.         httpService.addParam(type="formfield", name="remoteip", value="#cgi.remote_addr#");
  12.         //Parse Response and do error code
  13.         httpResponse = httpService.send().getPrefix();
  14.         temp = deserializeJSON(httpResponse.filecontent);
  15.         if(temp.success == 'no'){
  16.             arrayAppend(variables.errors_array,'Please check the captcha.');
  17.         }
  18.     }
  19. </cfscript>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement