谷歌reCaptcha实施;响应始终为NULL

时间:2018-01-04 16:45:08

标签: php recaptcha captcha

我有以下代码用于recaptcha veryfication。

$curl = curl_init();

$postfields = array(
  'secret' => '------Private Key------',
  'response' => $_POST['g-recaptcha-response'],
);

var_dump($_POST['g-recaptcha-response']);

$options = array(
  CURLOPT_RETURNTRANSFER => 1,
  CURLOPT_URL => 'https://www.google.com/recaptcha/api/siteverify',
  CURLOPT_POST => 1,
  CURLOPT_POSTFIELDS => $postfields,
);

curl_setopt_array($curl, $options);


$response = json_decode(curl_exec($curl), true);

问题是我得到的响应总是为NULL,无论如何。有人可以帮我这个吗?感谢

0 个答案:

没有答案