Advertisement
MrFastDie

recaptcha

Jan 16th, 2017
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.79 KB | None | 0 0
  1. function recaptcha($secredkey, $response){
  2.         $url = 'https://www.google.com/recaptcha/api/siteverify';
  3.         $data = array('secret' => $secredkey, 'response' => $response);
  4.  
  5.         $options = array(
  6.             'http' => array(
  7.                 'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
  8.                 'method'  => 'POST',
  9.                 'content' => http_build_query($data)
  10.             )
  11.         );
  12.        
  13.         $context  = stream_context_create($options);
  14.         $result = file_get_contents($url, false, $context);
  15.  
  16.         if ($result === FALSE) {
  17.             return False;
  18.          }
  19.  
  20.         $data = json_decode($result);
  21.  
  22.         if ($data->success == 1){
  23.             return True;
  24.         } else {
  25.             return False;
  26.         }
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement