Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I recently added recaptcha to a site and got this version.

From an implementation standpoint it is utterly painless. The client side is copy/paste from Google's site and the PHP/server side was this:

      $recapchaURL = 'https://www.google.com/recaptcha/api/siteverify?secret=600SZZ0ZZZZZIZi-ZZ0ZEHZW1000Z_0ZZZ00QZZ&response=' . request_var('g-recaptcha-response','') .'&remoteip=' . $request->server('REMOTE_ADDR');
      $recapchaRespone = file_get_contents($recapchaURL);
      if(is_null($recapchaRespone))
      {
            print("Recaptcha failed. <more error msg>"); return; 
      }
      $recapchaResponeJSON = json_decode($recapchaRespone);
      if(!( !is_null($recapchaResponeJSON->{'success'}) && $recapchaResponeJSON->{'success'} == 'true'))
      {
            print("Recaptcha failed. <more error msg>"); return;
       }    
Most of the time it just gives you that one checkbox, but if you use the form multiple times (e.g. testing) it starts to give you the classical text entry box. I have no idea how it works fully and this article only sheds little light on it.


Is that your actual secret? you might not want to reveal that/you should get a new one.


It is not. I kept the length and style the same to give a better example, but replaced most of the characters with 0s and Zs.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: