I have the following problem: My code works on localhost but doesn't work on live server.
My code:
$recaptcha_url = 'https://www.google.com/recaptcha/api/siteverify';
$recaptcha_secret = 'CAPTCHA_SECRET_KEY'; //secret key
$recaptcha_response = $_POST['g-recaptcha-response'];
$recaptcha = file_get_contents($recaptcha_url . '?secret=' .
$recaptcha_secret . '&response=' . $recaptcha_response);
$recaptcha = json_decode($recaptcha, true);
//something gets wrong here:
exit(var_export($recaptcha));
On localhost I get array ( 'success' => true, 'challenge_ts' => '2022-03-15T20:24:02Z', 'hostname' => 'localhost', 'score' => 0.9, 'action' => 'sent', )
On live server I get 'NULL'
. I tried to display the contents of file_get_contents but there I get "false" and I can't find the problem.