Get the graphic captcha, return the base64 encoding of the captcha image and captcha ID, used to prevent automated attacks and robot registration and other scenarios.
Points to note
- The interface does not require any request parameters
- The verification code image is provided in base64 encoding format and can be displayed directly on the front end
- Captcha ID is used for subsequent verification requests and should be kept safely
- The captcha is time-sensitive and needs to be retrieved again after expiration
Request address
{域名地址}/api/captcha
Description:{域名地址}Replace it with your domain name, such ashttps://en.anqicms.com/api/captcha
Request Syntax
GET {域名地址}/api/captcha
Request Headers
This interface involves only public request headers. For more information, please refer toCommon Request Headers (Common Request Headers).
Request parameters
None
Response header
This interface only involves common response headers. For more information, please refer toCommon Request Headers (Common Request Headers).
Return parameters
| Field name | Type | Description |
|---|---|---|
| code | int | Error code |
| msg | string | Error description |
| data | object | captcha content |
data parameter
| Field name | Type | Description |
|---|---|---|
| Captcha | string | The base64 encoded string of the captcha image |
| captcha_id | string | The ID of the captcha image |
Usage Example
Request example
GET /api/captcha HTTP/1.1
Host: your-domain.com
Content-Type: application/json
Response Example
{
"code": 0,
"data": {
"captcha": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPAAAABMCAIAAADcP63LAAAVH0lEQVR4nO",
"captcha_id": "g0HFYRQUrC9rYbX2EZMH"
},
"msg": ""
}
In the response ofcaptchaThe field is a complete base64 encoded image data that can be directly used for front-end display:
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPAAAABMCAIAAADcP63LAAAVH0lEQVR4nO" />
error code
| Error code | Description |
|---|---|
| 0 | OK |
| -1 | Error, the reason is indicated in msg |
| 1001 | Not logged in |
| 1002 | Not authorized |
| 200 | API request OK |