douzen1880 2014-12-14 19:18
浏览 42
已采纳

谷歌没有验证码仍显示文字

I have this code in my form:

<div class="g-recaptcha" data-sitekey="MY_KEY"></div>

And the validation part:

//  Re captcha part
    if (isset($_POST['g-recaptcha-response'])){
        $captcha = $_POST['g-recaptcha-response'];
    }
    if (!$captcha) {
        redirect('login', 'refresh');
    }

    $response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=MY_SECRET_KEY&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
    // t($response,1);
    if($response."success" == false) {
        redirect('login', 'refresh');
    }

It sort of works now, this is my result: enter image description here

When I click the checkbox, I still need to type the text for verification.

I thought that clicking the checkbox was enough?

Am I doing something wrong here?

  • 写回答

2条回答 默认 最新

  • duanjinchen5296 2014-12-18 13:51
    关注

    Here's how I check "No Captcha" response and it always shows me "one click" verification box, even in localhost:

    $g_recaptcha_response = filter_input(INPUT_POST, 'g-recaptcha-response');
    if (isset($g_recaptcha_response)) {
        $google = 'https://www.google.com/recaptcha/api/siteverify?secret='
                . ZorAuthConfig::RC_SECRET_KEY
                . '&response=' . $g_recaptcha_response;
        $google_json = file_get_contents($google);
        $google_data = json_decode($google_json);
        // Check reCaptcha response.
        if (!$google_data->success) {
            // Do something if robot.
        } else {
           // Do something if human.
        }
    }
    

    I implemented this in small library I wrote recently, so you can check it out if you want more details: https://github.com/zoran-petrovic-87/ZorAuth

    http://zoran87.blogspot.com/2014/12/zorauth-10b-complete-flexible-no.html

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)