【问题标题】:Captcha in Android ApplicationAndroid 应用程序中的验证码
【发布时间】:2018-08-20 11:41:54
【问题描述】:

我必须在我的 android 应用代码中实现 Captcha,但不知道如何去做..

谁能帮帮我??

【问题讨论】:

标签: android captcha


【解决方案1】:

看看SimpleCaptchaJCaptcha

【讨论】:

  • JCaptcha 当然。我不知道SimpleCaptcha,但应该也是。
【解决方案2】:

无耻的自我推销,但我讨厌所有其他选择,特别是它们都是基于网络的。现在,我确信我的需要大量工作等,并且可能不如使用其他外部解决方案安全,但至少它易于使用并且有一些选择。

Git it here, and have fun changing and committing

【讨论】:

  • 很棒的实现
【解决方案3】:

现在 Google 为此提供了 SafetyNet reCAPTCHA 库。
了解更多详情here

以下是实施 reCaptcha 的步骤:

  1. 添加 SafetyNet API 依赖项
dependencies {
    compile 'com.google.android.gms:play-services-safetynet:15.0.1'
}
  1. 使用 API(来自 google 文档的示例)

    public void onClick(View v) {
    SafetyNet.getClient(this).verifyWithRecaptcha(YOUR_API_SITE_KEY)
        .addOnSuccessListener((Executor) this,
            new OnSuccessListener<SafetyNetApi.RecaptchaTokenResponse>() {
                @Override
                public void onSuccess(SafetyNetApi.RecaptchaTokenResponse response) {
                    // Indicates communication with reCAPTCHA service was
                    // successful.
                    String userResponseToken = response.getTokenResult();
                    if (!userResponseToken.isEmpty()) {
                        // Validate the user response token using the
                        // reCAPTCHA siteverify API.
                    }
                }
        })
        .addOnFailureListener((Executor) this, new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    if (e instanceof ApiException) {
                        // An error occurred when communicating with the
                        // reCAPTCHA service. Refer to the status code to
                        // handle the error appropriately.
                        ApiException apiException = (ApiException) e;
                        int statusCode = apiException.getStatusCode();
                        Log.d(TAG, "Error: " + CommonStatusCodes
                                .getStatusCodeString(statusCode));
                    } else {
                        // A different, unknown type of error occurred.
                        Log.d(TAG, "Error: " + e.getMessage());
                    }
                }
        });
    

    }

【讨论】:

    猜你喜欢
    • 2011-05-14
    • 1970-01-01
    • 2015-09-22
    • 2019-05-07
    • 2012-06-24
    • 2012-06-13
    • 2017-03-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多