All Products
Search
Document Center

Captcha:Integrate CAPTCHA 2.0 into a business server

Last Updated:Jul 22, 2024

After you integrate CAPTCHA 2.0 into a business client, you must integrate CAPTCHA 2.0 into a business server, and then call the VerifyIntelligentCaptcha operation on the business server to initiate a verification request. This topic describes how to call the VerifyIntelligentCaptcha operation.

Prerequisites

An AccessKey pair is created for a Resource Access Management (RAM) user. For more information, see Create an AccessKey pair.

Important

Do not use the AccessKey pair of your Alibaba Cloud account. If the AccessKey pair of your Alibaba Cloud account is leaked, the resources that belong to the account are exposed to potential risks. Use the AccessKey pair of a RAM user instead to reduce the risks of AccessKey pair leaks. To use CAPTCHA 2.0 as a RAM user, you must attach the AliyunYundunAFSFullAccess policy to the RAM user.

Download and install the SDK

  1. Go to the Alibaba Cloud CAPTCHA 2.0 Sample Code Center page of OpenAPI Explorer and download the CAPTCHA 2.0 server SDK package of the required programming language based on the development environment of your business server.

    CAPTCHA 2.0 provides server SDKs for Java, TypeScript, Go, PHP, Python, C#, and Darabonba.

    image.png

  2. Decompress the SDK package and load it to your business server project.

Call the VerifyIntelligentCaptcha operation

Note

If you have questions when you call the operation, submit a ticket to contact technical support.

Initiate a verification request

  • Operation: VerifyIntelligentCaptcha

  • Endpoint: captcha.ap-southeast-1.aliyuncs.com

    Note

    If your server is located in the Chinese mainland, the endpoint is captcha.cn-shanghai.aliyuncs.com.

  • Request method: POST

  • Transfer protocol: HTTPS

  • Description: After you integrate CAPTCHA 2.0 into a business client, call this operation on the business server to initiate a verification request.

Request parameters

Parameter

Type

Required

Description

Example

CaptchaVerifyParam

String

Yes

The verification parameters that are returned by the CAPTCHA script in callback mode. Pass all parameters that are obtained from the business client to the business server.

Warning

Do not modify the verification parameters. Otherwise, a service error occurs.

{"sceneId":"xxxxxx","certifyId":"xxxxxx","deviceToken":"xxxxxxx==","data":"xxxxxx==","..."}

SceneId

String

No

The scenario ID of the verification request. We recommend that you specify this parameter. This prevents the verification request in this scenario from being confused with that in other scenarios.

Udw***d72

Response parameters

Parameter

Type

Description

HTTP Status Code

Integer

The HTTP status code. For more information, see the following table.

HTTP Body

RequestId

String

The request ID.

Success

Boolean

Indicates whether the request was successful. Valid values:

  • true

  • false

Code

String

The response code. For more information, see the following table.

Message

String

The returned message. For more information, see the following table.

Result

VerifyResult

Boolean

Indicates whether the verification was passed. Valid values:

  • true

  • false

VerifyCode

String

The error code. Valid values:

  • F001: The verification failed.

  • F002: The CaptchaVerifyParam parameter is not specified.

  • F003: The format of the CaptchaVerifyParam parameter is invalid. For more information, see the documentation of CAPTCHA 2.0.

  • F004: The verification failed because the test mode is enabled in the CAPTCHA 2.0 console.

  • F005: The scenario ID does not exist.

  • F006: The scenario ID does not belong to the current account.

  • F007: The verification timed out.

  • F008: The verification data already exists.

  • F009: A virtual device is detected. Use a physical device.

  • F010: The number of requests from the same IP address exceeds the limit.

  • F011: The number of requests from the same device exceeds the limit.

  • F012: The scenario ID that you specified is inconsistent with that specified by the CaptchaVerifyParam parameter.

  • F013: The value of the CaptchaVerifyParam parameter is incomplete.

The following table describes the HTTP Status Code, Code, and Message parameters.

HTTP Status Code

Code

Message

200

Success

The request was successful.

400

MissingParameter

One or more required parameters are not specified.

401

InvalidParameter

One or more specified parameters are invalid.

403

Forbidden.AccountAccessDenied

You do not have the required permissions. The service may not be activated, or your account may have overdue payments.

403

Forbidden.RAMUserAccessDenied

The RAM user does not have the required permissions. Attach the AliyunYundunAFSFullAccess policy to the RAM user. For more information, see Grant permissions to a RAM role.

500

InternalError

An internal error has occurred. Try again later. If the error persists, submit a ticket to contact technical support.