After you complete the client-side integration, call the VerifyIntelligentCaptcha API from your server to complete the verification. This topic describes how to call the VerifyIntelligentCaptcha API.
Prerequisites
Create access credentials. The Captcha 2.0 server supports API calls that use various methods, such as an AccessKey or a Security Token Service (STS) token. For more information, see Initialize a credential client.
Do not use the AccessKey of your Alibaba Cloud account. If your AccessKey is leaked, all your cloud resources are at risk. Use the AccessKey of a Resource Access Management (RAM) user to reduce security risks. To use Alibaba Cloud Captcha, grant the AliyunYundunAFSFullAccess permission to the RAM user.
Download and install the SDK
Download the server-side software development kit (SDK) package for your programming language from the OpenAPI Developer Portal. Captcha 2.0 provides server-side SDKs for Java, TypeScript, Go, PHP, Python, .NET, C++, and Swift.
Supported languages
SDK download address
GitHub source address
Java
Python
TypeScript
Go
PHP
Swift
C++
.NET
Decompress the SDK package and load it into your server-side project.
Call the VerifyIntelligentCaptcha API
Send an authentication request
API name: VerifyIntelligentCaptcha
The value of the region parameter in AliyunCaptchaConfig must be correctly mapped to the server-side endpoint. Otherwise, the verification request returns an error.
Endpoint
Value of the region parameter for client-side integration
Corresponding server-side endpoint
Dual-stack support for the signature verification domain name
The Chinese mainland (Shanghai)
cn
IPv4: captcha.cn-shanghai.aliyuncs.com
Supports only IPv4
Dual-stack: captcha-dualstack.cn-shanghai.aliyuncs.com
Supports both IPv4 and IPv6
Outside the Chinese mainland (Singapore)
sgp
IPv4: captcha.ap-southeast-1.aliyuncs.com
Supports only IPv4
Dual-stack: captcha-dualstack.ap-southeast-1.aliyuncs.com
Supports both IPv4 and IPv6
Request method: POST
Transport protocol: HTTPS
API description: Call this API from the server to perform verification after you configure the client-side Captcha.
Request parameters
Name | Type | Required | Description | Example |
CaptchaVerifyParam | String | Yes | The verification parameter that is returned by the Captcha script callback. Pass all parameter information from the client to the server. Warning Do not modify the verification parameter. Otherwise, a business error occurs. |
|
SceneId | String | No | The ID of the scenario for the current verification. Specify this parameter on your server, especially in multi-scenario deployments, to prevent the frontend from being tampered with to use other scenarios. | Udw***d72 |
Response parameters
Name | Type | Description | |||
HTTP Status Code | Integer | The HTTP status code. For more information, see Description of response parameters. | |||
HTTP Body | RequestId | String | The request ID. | ||
Success | Boolean | Indicates whether the request was successful.
| |||
Code | String | The return code. For more information, see Description of response parameters. | |||
Message | String | The detailed information. For more information, see Description of response parameters. | |||
Result | VerifyResult | Boolean | The verification result.
| ||
VerifyCode | String | T001 | The server-side verification is passed. | ||
T005 | Test mode is enabled in the console and configured to pass verifications. If you have questions, log on to the Captcha 2.0 console to view the policy status configuration for the scenario. For more information, see Integration guide. | ||||
F001 | A suspected attack request. The request is blocked by a risk control policy. | ||||
F002 | The | ||||
F003 | The format of the | ||||
F004 | Test mode is enabled in the console and configured to block verifications. If you have questions, log on to the Captcha 2.0 console to view the policy status configuration for the scenario. For more information, see Manage scenarios. | ||||
F005 | The scene ID (sceneId) in CaptchaVerifyParam is invalid. CaptchaVerifyParam is automatically obtained by the frontend and passed to your server. Do not modify this parameter. Pass it directly to Alibaba Cloud. For more information, see Server-side integration to check your integration code. | ||||
F006 | The scene ID (sceneId) in | ||||
F008 | The verification data is submitted repeatedly. A verification code request can be submitted only once. | ||||
F009 | A virtual device environment is detected. Check whether you are using virtual machines such as VMware, VirtualBox, Hyper-V, or Parallels, emulators such as AVD, BlueStacks, or VBox/Hyper-V, or a desktop browser to impersonate a mobile device. If you do not want to block these requests, log on to the Captcha 2.0 console and disable this feature in the custom policy. For more information, see Set a custom policy. | ||||
F010 | The access frequency from the same IP address exceeds the limit. To customize the frequency threshold, log on to the Captcha 2.0 console and configure a custom policy. For more information, see Set a custom policy. | ||||
F011 | The access frequency from the same device exceeds the limit. To customize the frequency threshold, log on to the Captcha 2.0 console and configure a custom policy. For more information, see Set a custom policy. | ||||
F012 | The SceneID passed in your server-side parameters must be the same as the SceneId configured on the frontend. | ||||
F013 | The | ||||
F014 | No initialization record is found. This may be due to two reasons:
| ||||
F015 | The verification interaction failed. For example, the puzzle piece was not moved to the correct position. You can refresh the Captcha and try again. | ||||
F016 | The request is blocked because of the URL verification configured in a custom policy in the console. Log on to the Captcha 2.0 console to adjust the URL verification policy. For more information, see Set a custom policy. | ||||
F017 | A suspected attack request. The request is blocked due to an abnormal protocol or parameter. | ||||
F018 | In the V3 architecture, the request parameter CaptchaVerifyParam for the business signature verification request is reused. | ||||
F019 | In the V3 architecture, the interval between the behavior verification request and the business signature verification request exceeds 90 seconds, or the business signature verification request is sent without a preceding behavior verification request. | ||||
F020 | In the V3 architecture, the CaptchaVerifyParam of the business signature verification request does not match the scene ID or user. | ||||
CertifyID | String |
| |||
The following table describes the HTTP Status Code, Code, and Message response parameters.
HTTP Status Code | Code | Message |
200 | Success | The request is successful. |
400 | MissingParameter | A required parameter is missing. |
401 | InvalidParameter | The parameter is invalid. |
403 | Forbidden.AccountAccessDenied | You are not authorized to perform the operation. The service may not be activated, or your account may have an overdue payment. |
403 | Forbidden.RAMUserAccessDenied | The RAM user is not authorized to perform the operation. Grant the AliyunYundunAFSFullAccess permission to the RAM user. For more information, see Grant permissions to a RAM role. |
500 | InternalError | An internal error occurred. We recommend that you retry the request. |