我正在使用reCAPATCHA在Web窗体上。我通过cURL验证了CAPTCHA服务器端。不打印JSON响应(cURL)
$post = [
'secret' => '6LeGbxkUAAAAAGOiOLDlzRiLV6JBMSF5nTyObE9G',
'response' => $_POST['g-recaptcha-response'],
'remoteip' => $_SERVER['REMOTE_ADDR']
];
//cURL and confirm the reCAPTCHA
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify");
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($ch);
curl_close($ch);
if($response['success'] == true) {
header("Location: https://website.com/contact.php?res=1");
} else {
//print('reCAPTCHA failed.');
header("Location: https://website.com/contact.php?res=2");
}
的JSON响应{ "success": false, "error-codes": [ "missing-input-response" ] }
会发生什么事是卷曲自动打印JSON的浏览器,阻止我重定向页面。有没有办法阻止cURL打印JSON或以不同的方式重定向?我试图通过文档和其他地方寻找,并没有找到答案。我也尝试将$response
作为字符串打印并将其编码为JSON,但这也不起作用。
不添加给出的回答你能告诉我你已经保存在您的变量'$ response'什么反应 –
请分享你'$ response' –