如何不使用file_get_contents从Google的ReCaptcha获取信息?

时间:2018-08-09 08:59:22

标签: php 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) {

1 个答案:

答案 0 :(得分:0)

您应该使用Google提供的官方reCAPTCHA类,它使用cURL并且易于使用:https://github.com/google/recaptcha