English 中文(简体)
• 如何将“回头”带入一个 flu的 app。
原标题:How to implement reCaptcha into a flutter app

我正试图将“Captcha”功能落实到我的冲破片面上,但在“上限”登记中,我需要提供一个我没有一个供移动用的领域。 我已浏览了几本指南,教导如何将回流改成一个移动式器,但这些指南用包裹名称而不是域名登记了回流。 如何以正确的方式在2020年冲碎机或任何移动用具中进行回流?

最佳回答

您可使用这一缩略语:flutter_recaptcha

就这个领域而言,我也有同样的问题。 我首先发现,我需要从here,我必须检查,其中对此作了解释。

<><>Edit>/strong>

I noticed something after trying it out, that I d like to mention. The plugin does not provide a captcha response for using to authenticate the user server-side, so it does not seem very useful as it is. However, it is a simple plugin, so it may be possible to use it as an example. The steps, I think, would be to create a webpage with the captcha. As with the plugin, use a webview to open the page, then capture the post output of the form and ip address of user submitting the form, using something like this, then send it to flutter and then submit your request with that information, and use the Google library to verify the captcha.

<<>Instructions>

I just finished implementing this and I found a good way that works. First, create an html page, like this:

<html>
  <head>
    <title>reCAPTCHA</title>
    <script src="https://www.google.com/recaptcha/api.js" async defer></script>
  </head>
  <body style= background-color: aqua; >
    <div style= height: 60px; ></div>
    <form action="?" method="POST">
      <div class="g-recaptcha" 
        data-sitekey="YOUR-SITE-KEY"
        data-callback="captchaCallback"></div>
      
    </form>
    <script>
      function captchaCallback(response){
        //console.log(response);
        if(typeof Captcha!=="undefined"){
          Captcha.postMessage(response);
        }
      }
    </script>
  </body>
</html>

然后,在你的领域,例如:com/captcha。

之后,就会产生一个挥霍的植被:

import  dart:async ;

import  package:flutter/material.dart ;
import  package:webview_flutter/webview_flutter.dart ;

class Captcha extends StatefulWidget{
  Function callback;
  Captcha(this.callback);

  @override
  State<StatefulWidget> createState() {
    return CaptchaState();
  }

}
class CaptchaState extends State<Captcha>{
  WebViewController webViewController;
  @override
  initState(){
    super.initState();
  }


  @override
  Widget build(BuildContext context) {
    return Center(
      child: WebView(
        initialUrl: "https://example.com/captcha.html",
        javascriptMode: JavascriptMode.unrestricted,
        javascriptChannels: Set.from([
          JavascriptChannel(
            name:  Captcha ,
            onMessageReceived: (JavascriptMessage message) {
              //This is where you receive message from
              //javascript code and handle in Flutter/Dart
              //like here, the message is just being printed
              //in Run/LogCat window of android studio
              //print(message.message);
              widget.callback(message.message);
              Navigator.of(context).pop();
            })
        ]),
        onWebViewCreated: (WebViewController w) {
          webViewController = w;
        },
      )
    );
  }

}

确保在。 (右边“Admin Console”的浮标)。

之后,你建立了前线。 • 简讯:

Navigator.of(context).push(
                  MaterialPageRoute(
                    builder: (context){
                      return Captcha((String code)=>print("Code returned: "+code));
                    }
                  ),
                );

你们可以利用你想要的那种挫折:

class GenericState extends State<Generic>{
void methodWithCaptcha(String captchaCode){
  // Do something with captchaCode
}

@override
  Widget build(BuildContext context) {
    return Center(child:FlatButton(
        child: Text("Click here!"),
        onPressed: (){
            Navigator.of(context).push(
                  MaterialPageRoute(
                    builder: (context){
                      return Captcha(methodWithCaptcha);
                    }
                  ),
                );
        }
  }
}

页: 1 (一) 沿用“射线”和“Usage”两节。 我发现,就使用而言,我只能使用守则:

$recaptcha = new ReCaptchaReCaptcha($secret);
$resp = $recaptcha->verify($gRecaptchaResponse, $remoteIp);
if ($resp->isSuccess()) {
    // Verified!
} else {
    $errors = $resp->getErrorCodes();
}

如上所示,没有必要使用<代码>。

之后,一切都奏效! 我认为,这目前是执行谷歌回Captcha V2冲破(针对Si和Andre)的最佳途径。

问题回答

如果你在寻找液压碎的WEB,你可以尝试g_recaptcha_v3。 一揽子计划

注:

  • it supports reCAPTCHA V3 only and not V2
  • its for Flutter Web only and no other platform supports

I ve improved @JVE999 approach and created a new package: flutter_firebase_recaptcha

一揽子方案使用<条码>InAppWebView,用于检索超文本,因此,你不需要再单独网页。

我的宽宏图支持可见和看不见的回流。 看不见的回流使你在不向用户展示任何东西的情况下试图重新cap。

you can use flutter_gcapthca_v3. It works with the current google recaptcha v3 and supports Android/IOS platform.

void buildCaptcha() {
const letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
const length = 6;
final random = Random();
final randomString = String.fromCharCodes(List.generate(
    length, (index) => letters.codeUnitAt(random.nextInt(letters.length))));
print("the random string is ${randomString}");
}




相关问题
Recaptcha ErrorMessage Property in ASP.NET

I am using recaptcha in an ASP.NET 3.5 application and for some odd reason the ErrorMessage property is not working. Below is my code <recaptcha:RecaptchaControl ID="recaptcha" runat="server" ...

Testing ReCaptcha Dynamically?

I ve got recaptcha working in it s fundamental form - requiring a captcha code and displaying a basic error when it s wrong. But I want to make it more usable, and I d really appreciate your help. Is ...

reCAPTCHA-like Web Service in other Languages

Is there a CAPTCHA web service like reCAPTCHA that supports languages other than English? It would be nice to have localized CAPTCHAs for non-English users.

Zend framework and ReCaptcha

I need to insert ReCaptcha in a form in my ZF application. I m trying to follow the official documentation, but the ReCaptcha service return me always the error incorrect-captcha-sol . The code I m ...

Recaptcha - Form Customization

Does anyone know if recaptcha can be fully customize without the default frame. I need the recaptcha image to only be a certain width as well as the input field. Has anyone done this before with ...

热门标签