php - 如何在不使用 file_get_contents 的情况下从 Google 的 ReCaptcha 中获取?
问题描述
我的托管服务器不允许file_get_contents
。如何在不使用该调用的情况下获得 reCaptcha 的服务器验证?
$recaptcha_secret = "";
$response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$recaptcha_secret."&response=".$_POST['g-recaptcha-response']);
$responseKeys = json_decode($response,true);
if ($responseKeys["success"]==true) {
解决方案
您应该使用 Google 提供的官方 reCAPTCHA 类,它使用 cURL 并且易于使用:https ://github.com/google/recaptcha