簡體   English   中英

用戶確認自己不是機器人后,如何獲取recaptcha客戶端驗證參數g-recaptcha-response?

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

我正在嘗試以某種形式實現Google Recaptcha。 該表單向服務器發出HTTP發布請求,並在其中將for數據作為JSON對象發送。

我在帶有以下div標簽的表單提交按鈕之前添加了Google reCAPTCHA:

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

另外,我還在head標簽中添加了所需的JavaScript文件:

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

現在,提交按鈕向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();
    });
};

該表格被提交給REST服務。

問題是,在哪里可以找到g-recaptcha-response參數,以便將其與JSON對象一起發送回服務器? 因為我需要此響應值來執行服務器端用戶驗證。

我正在關注這里發布的文檔

grecaptcha.getResponse(widget_id);

這會給您recapcha的響應。 如果您使用的是Angular,請在表單提交功能中使用它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM