Paste Code
Paste Blends
Paste Images
if (isset($_POST["g-recaptcha-response"])) {
$recaptcha_url = "https://www.google.com/recaptcha/api/siteverify";
$recaptcha_data = array("secret" => "my_secret_key", "response" => $_POST["g-recaptcha-response"]);
$recaptcha_options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencodedrn",
'method' => 'POST',
'content' => http_build_query($recaptcha_data)
)
);
$recaptcha_context = stream_context_create($recaptcha_options);
$recaptcha_result = file_get_contents($recaptcha_url, false, $recaptcha_context);

/* should return a JSON object https://developers.google.com/recaptcha/docs/verify
{
"success": true|false,
"challenge_ts": timestamp
}
*/

$recaptcha_json = json_decode($recaptcha_result, true);
echo var_dump($recaptcha_json); /* <- I want first key "success" */
}
  1. if (isset($_POST["g-recaptcha-response"])) {
  2.     $recaptcha_url = "https://www.google.com/recaptcha/api/siteverify";
  3.     $recaptcha_data = array("secret" => "my_secret_key", "response" => $_POST["g-recaptcha-response"]);
  4.     $recaptcha_options = array(
  5.         'http' => array(
  6.             'header' => "Content-type: application/x-www-form-urlencodedrn",
  7.             'method' => 'POST',
  8.             'content' => http_build_query($recaptcha_data)
  9.         )
  10.     );
  11.     $recaptcha_context = stream_context_create($recaptcha_options);
  12.     $recaptcha_result = file_get_contents($recaptcha_url, false, $recaptcha_context);
  13.  
  14.      /* should return a JSON object https://developers.google.com/recaptcha/docs/verify
  15.       {
  16.         "success": true|false,
  17.         "challenge_ts": timestamp
  18.       }
  19.      */
  20.  
  21.     $recaptcha_json = json_decode($recaptcha_result, true);
  22.     echo var_dump($recaptcha_json); /* <- I want first key "success" */
  23. }
go to heaven