Allow users to evaluate purchased products or orders, supporting text evaluation, rating, and image upload.
Points to note
- The API uses the POST method and requires data to be submitted in application/ format
- Provide document ID and review content
- Supports logged-in users and non-logged-in users (non-logged-in users must provide a username)
- Can be associated with a specific order through order ID
- Supports a 1-5 point rating system
- Supports uploading multiple review images
- Reviews need to be approved before they can be displayed
Request address
{域名地址}/api/review/publish
Description:{域名地址}Replace it with your domain name, such ashttps://en.anqicms.com/api/review/publish
Request Syntax
POST {域名地址}/api/review/publish
Content-Type: application/json
Request Headers
| Field name | Type | Required | Description |
|---|---|---|---|
| token | string | No | User login token, can be omitted for non-logged-in users |
This interface also involves common request headers. For more information, please refer toCommon Request Headers (Common Request Headers).
Request parameters
| Field name | Type | Required | Description |
|---|---|---|---|
| archive_id | int | Is | Document ID of the review |
| content | string | Is | Review Content |
| Score | int | Is | Rating, 1-5 points |
| user_name | string | No | Username (required for non-logged-in users) |
| string | No | Email address (optional for non-logged-in users) | |
| order_id | string | No | Order ID, associated with a specific order |
| Images | string array | No | Evaluation image array, need to upload through the upload interface first, put the image address here |
Response header
This interface only involves public 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 |
Usage Example
Request example
POST /api/review/publish HTTP/1.1
Host: www.anqicms.com
Content-Type: application/json
{
"archive_id": 140,
"content": "这个产品非常棒,质量很好,发货也很快!",
"score": 5,
"order_id": "202211232209080046",
"images": [
"https://en.anqicms.com/uploads/review/image1.jpg",
"https://en.anqicms.com/uploads/review/image2.jpg"
]
}
Response Example
{
"code": 0,
"msg": "发布成功"
}
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 |
| 4001 | Evaluation content cannot be empty |
| 4002 | Rating must be between 1 and 5 |
| 4003 | Invalid document ID |
| 4004 | Cannot review the product, not purchased |
| 4005 | Product has already been reviewed |