MrFastDie icon

recaptcha

MrFastDie | PRO | 01/16/17 04:43:22 PM UTC | 0 ⭐ | 385 👁️ | Never ⏰ | []
PHP |

790 B

|

None

|

0 👍

/

0 👎

function recaptcha($secredkey, $response){
        $url = 'https://www.google.com/recaptcha/api/siteverify';
        $data = array('secret' => $secredkey, 'response' => $response);
 
        $options = array(
            'http' => array(
                'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
                'method'  => 'POST',
                'content' => http_build_query($data)
            )
        );
        
        $context  = stream_context_create($options);
        $result = file_get_contents($url, false, $context);
 
        if ($result === FALSE) { 
            return False;
         }
 
        $data = json_decode($result);
 
        if ($data->success == 1){
            return True;
        } else {
            return False;
        }
    }

Comments