Messwerte für reCAPTCHA-Websiteschlüssel abrufen
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Messwerte für einen bestimmten reCAPTCHA-Websiteschlüssel abrufen
Codebeispiel
Nächste Schritte
Wenn Sie nach Codebeispielen für andere Google Cloud -Produkte suchen und filtern möchten, können Sie den Google Cloud -Beispielbrowser verwenden.
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],[],[],[],null,["# Get reCAPTCHA site key metrics\n\nGet metrics specific to a reCAPTCHA site key.\n\nCode sample\n-----------\n\n### Java\n\n\nTo authenticate to reCAPTCHA, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n\n import com.google.cloud.recaptchaenterprise.v1.https://cloud.google.com/java/docs/reference/google-cloud-recaptchaenterprise/latest/com.google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient.html;\n import com.google.recaptchaenterprise.v1.https://cloud.google.com/java/docs/reference/google-cloud-recaptchaenterprise/latest/com.google.recaptchaenterprise.v1.GetMetricsRequest.html;\n import com.google.recaptchaenterprise.v1.https://cloud.google.com/java/docs/reference/google-cloud-recaptchaenterprise/latest/com.google.recaptchaenterprise.v1.Metrics.html;\n import com.google.recaptchaenterprise.v1.https://cloud.google.com/java/docs/reference/google-cloud-recaptchaenterprise/latest/com.google.recaptchaenterprise.v1.MetricsName.html;\n import com.google.recaptchaenterprise.v1.https://cloud.google.com/java/docs/reference/google-cloud-recaptchaenterprise/latest/com.google.recaptchaenterprise.v1.ScoreMetrics.html;\n import java.io.IOException;\n\n public class GetMetrics {\n\n public static void main(String[] args) throws IOException {\n String projectId = \"project-id\";\n String recaptchaSiteKey = \"recaptcha-site-key\";\n\n getMetrics(projectId, recaptchaSiteKey);\n }\n\n /**\n * Get metrics specific to a recaptcha site key. E.g: score bucket count for a key or number of\n * times the checkbox key failed/ passed etc.,\n *\n * @param projectId: Google Cloud Project Id.\n * @param recaptchaSiteKey: Specify the site key to get metrics.\n */\n public static void getMetrics(String projectId, String recaptchaSiteKey) throws IOException {\n // Initialize client that will be used to send requests. This client only needs to be created\n // once, and can be reused for multiple requests. After completing all of your requests, call\n // the `client.close()` method on the client to safely\n // clean up any remaining background resources.\n try (https://cloud.google.com/java/docs/reference/google-cloud-recaptchaenterprise/latest/com.google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient.html client = https://cloud.google.com/java/docs/reference/google-cloud-recaptchaenterprise/latest/com.google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient.html.create()) {\n\n https://cloud.google.com/java/docs/reference/google-cloud-recaptchaenterprise/latest/com.google.recaptchaenterprise.v1.GetMetricsRequest.html getMetricsRequest =\n https://cloud.google.com/java/docs/reference/google-cloud-recaptchaenterprise/latest/com.google.recaptchaenterprise.v1.GetMetricsRequest.html.newBuilder()\n .setName(https://cloud.google.com/java/docs/reference/google-cloud-recaptchaenterprise/latest/com.google.recaptchaenterprise.v1.MetricsName.html.of(projectId, recaptchaSiteKey).toString())\n .build();\n\n https://cloud.google.com/java/docs/reference/google-cloud-recaptchaenterprise/latest/com.google.recaptchaenterprise.v1.Metrics.html response = client.getMetrics(getMetricsRequest);\n\n // Retrieve the metrics you want from the key.\n // If the site key is checkbox type: then use response.getChallengeMetricsList() instead of\n // response.getScoreMetricsList()\n for (https://cloud.google.com/java/docs/reference/google-cloud-recaptchaenterprise/latest/com.google.recaptchaenterprise.v1.ScoreMetrics.html scoreMetrics : response.https://cloud.google.com/java/docs/reference/google-cloud-recaptchaenterprise/latest/com.google.recaptchaenterprise.v1.Metrics.html#com_google_recaptchaenterprise_v1_Metrics_getScoreMetricsList__()) {\n // Each ScoreMetrics is in the granularity of one day.\n int scoreBucketCount = scoreMetrics.getOverallMetrics().getScoreBucketsCount();\n System.out.println(scoreBucketCount);\n }\n System.out.printf(\"Retrieved the bucket count for score based key: %s\", recaptchaSiteKey);\n }\n }\n }\n\n### Python\n\n\nTo authenticate to reCAPTCHA, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n from google.cloud import https://cloud.google.com/python/docs/reference/recaptchaenterprise/latest/\n\n\n def get_metrics(project_id: str, recaptcha_site_key: str) -\u003e None:\n \"\"\"Get metrics specific to a recaptcha site key.\n E.g: score bucket count for a key or number of\n times the checkbox key failed/ passed etc.,\n Args:\n project_id: Google Cloud Project ID.\n recaptcha_site_key: Specify the site key to get metrics.\n \"\"\"\n\n client = https://cloud.google.com/python/docs/reference/recaptchaenterprise/latest/.https://cloud.google.com/python/docs/reference/recaptchaenterprise/latest/google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service.RecaptchaEnterpriseServiceClient.html()\n\n metrics_name = f\"projects/{project_id}/keys/{recaptcha_site_key}/metrics\"\n request = https://cloud.google.com/python/docs/reference/recaptchaenterprise/latest/.https://cloud.google.com/python/docs/reference/recaptchaenterprise/latest/google.cloud.recaptchaenterprise_v1.types.GetMetricsRequest.html()\n request.name = metrics_name\n\n response = client.https://cloud.google.com/python/docs/reference/recaptchaenterprise/latest/google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service.RecaptchaEnterpriseServiceClient.html#google_cloud_recaptchaenterprise_v1_services_recaptcha_enterprise_service_RecaptchaEnterpriseServiceClient_get_metrics(request)\n\n # Retrieve the metrics you want from the key.\n # If the site key is checkbox type: then use response.challenge_metrics\n # instead of response.score_metrics\n for day_metric in response.score_metrics:\n # Each 'day_metric' is in the granularity of one day.\n score_bucket_count = day_metric.overall_metrics.score_buckets\n print(score_bucket_count)\n\n print(f\"Retrieved the bucket count for score based key: {recaptcha_site_key}\")\n\n### Ruby\n\n\nTo authenticate to reCAPTCHA, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n require \"google/cloud/recaptcha_enterprise\"\n\n # Get metrics specific to a recaptcha site key.\n # E.g: score bucket count for a key or number of\n # times the checkbox key failed/ passed etc.,\n #\n # @param project_id [String] GCloud Project ID.\n # @param site_key [String] Site key to be updated.\n # @return [void]\n def get_metrics_site_key project_id:, site_key:\n # Create the reCAPTCHA client.\n client = ::Google::Cloud::RecaptchaEnterprise.recaptcha_enterprise_service\n\n response = client.get_metrics name: \"projects/#{project_id}/keys/#{site_key}/metrics\"\n\n # Retrieve the metrics you want from the key.\n # If the site key is checkbox type: then use response.challenge_metrics\n # instead of response.score_metrics\n puts \"Retrieved the bucket count for score based key: #{site_key}\"\n response.score_metrics.each do |day_metric|\n # Each 'day_metric' is in the granularity of one day.\n score_bucket_count = day_metric.overall_metrics.score_buckets\n puts score_bucket_count.inspect\n end\n end\n\nWhat's next\n-----------\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=recaptcha_enterprise)."]]