简体   繁体   English

用户确认自己不是机器人后,如何获取recaptcha客户端验证参数g-recaptcha-response?

[英]how to get recaptcha client verification parameter g-recaptcha-response after user confirms he is not a robot?

I am trying to implement Google recaptcha in a form. 我正在尝试以某种形式实现Google Recaptcha。 The form issues an HTTP post request to a server where it sends the for data as a JSON object. 该表单向服务器发出HTTP发布请求,并在其中将for数据作为JSON对象发送。

I added Google reCAPTCHA just before the form submit button with the following div tag: 我在带有以下div标签的表单提交按钮之前添加了Google reCAPTCHA:

     <div class="g-recaptcha" data-sitekey="{SITE_KEY}"></div>

Also I added the required JavaScript file in the head tag: 另外,我还在head标签中添加了所需的JavaScript文件:

 <script src='https://www.google.com/recaptcha/api.js'></script>

Now the submit button issues a request to a JavaScript function as follows: hence I am using Angular JS 现在,提交按钮向JavaScript函数发出如下请求:因此,我正在使用Angular JS

  $scope.issueVideoUploadRequest = function () {

    var requestVideoUploadParameters = {
        videoSource: $scope.videoSource,
        title: $scope.title,
        description: $scope.description,
        videoLanguage: $scope.language,
        tagsList: $scope.tagsList
    };
    $http({
        method: "POST",
        dataType: "json",
        data: requestVideoUploadParameters,
        url: 'http://localhost:8080/OampSeniorProjectV2/rs/content/requestUploadForm'
    }).success(function (response, status, headers) {
        $scope.alertMessageVideoRequest = response;
        alert(response);
    }).error(function (response, status, headers, config) {
        $scope.reloadPage();
    });
};

The form is submitted to a REST services. 该表格被提交给REST服务。

The question is, where to find the g-recaptcha-response parameter so I send it back to the server along with the form JSON object? 问题是,在哪里可以找到g-recaptcha-response参数,以便将其与JSON对象一起发送回服务器? As I need this response value to perform the server side user verification. 因为我需要此响应值来执行服务器端用户验证。

I was following the documentation posted here 我正在关注这里发布的文档

grecaptcha.getResponse(widget_id); grecaptcha.getResponse(widget_id);

This will give you the response of the recaptcha. 这会给您recapcha的响应。 Use this in your form submit function if you're using Angular. 如果您使用的是Angular,请在表单提交功能中使用它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 谷歌reCaptcha - 如何获得g-recaptcha-response - 没有FORM TAG - Google reCaptcha - How to get g-recaptcha-response - without FORM TAG 如何以在线形式删除 g-recaptcha-response? - How can I remove g-recaptcha-response in online form? ValidationError:不允许“ g-recaptcha-response” - ValidationError: “g-recaptcha-response” is not allowed #g-recaptcha-response 不要在 puppeteer 中加载 - #g-recaptcha-response dont load in puppeteer reCAPTCHA:缺少“g-recaptcha-response”的 POST 响应 - reCAPTCHA: Missing POST response for 'g-recaptcha-response' 不可见的reCAPTCHA发送具有多种形式的空g-captcha-chasponse - Invisible reCAPTCHA sending empty g-recaptcha-response with multiple forms $ _POST [“ g-recaptcha-response”],它在Captcha div元素中存储在哪里? 如何使用AJAX处理Recaptcha? - $_POST[“g-recaptcha-response”], where is it stored in the Captcha div element? How to handle Recaptcha with AJAX? 禁用提交按钮,直到 recaptcha3 g-recaptcha-response 值被检索 - Disable submit button until recaptcha3 g-recaptcha-response value is retrived 通过将g-recaptcha-response传递给javascript文件中的php文件来验证Google Recaptcha - Validating google recaptcha by passing g-recaptcha-response to php file from a javascript file 带Recaptcha v3的phpmailer不发送电子邮件-未定义索引:g-recaptcha-response - phpmailer with recaptcha v3 doesn't send email - Undefined index: g-recaptcha-response
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM