[英]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.
因为我需要此响应值来执行服务器端用户验证。
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.