Check if the specified product or document has been favorited by the current user, supporting single or batch query of favorite status.
Points to note
- The API uses the POST method and requires data to be submitted in application/ format
- Provide the document ID or an array of document IDs
- Only logged-in users can query their own favorite status
- Supports single document query and batch query
- The returned collection record includes detailed information such as collection time
Request address
{域名地址}/api/favorite/check
Description:{域名地址}Replace it with your domain name, such ashttps://en.anqicms.com/api/favorite/check
Request Syntax
POST {域名地址}/api/favorite/check
Content-Type: application/json
Request Headers
This interface involves only public request headers. For more information, please refer toCommon Request Headers (Common Request Headers).
Request parameters
| Field name | Type | Required | Description |
|---|---|---|---|
| archive_id | int | No | Document ID, either one with archive_ids |
| archive_ids | int[] | No | Document ID array, supports batch queries, either or both of archive_id |
Note: archive_idandarchive_idsEither parameter, priority is usedarchive_idsPerform batch query
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 |
| data | array | Return collection data array |
Parameters of data array elements
| Field name | Type | Description |
|---|---|---|
| id | int | Collection record ID |
| archive_id | int | Document ID |
| sku_id | int | SKU ID (if applicable) |
| user_id | int | User ID |
| create_time | int | favorite timestamp |
Usage Example
example of a single document query request
POST /api/favorite/check HTTP/1.1
Host: www.anqicms.com
Content-Type: application/json
{
"archive_id": 1
}
example of a batch document query request
POST /api/favorite/check HTTP/1.1
Host: www.anqicms.com
Content-Type: application/json
{
"archive_ids": [1, 2, 3, 5]
}
Example of a single document query response
{
"code": 0,
"msg": "",
"data": [
{
"id": 1,
"archive_id": 1,
"sku_id": 0,
"user_id": 1,
"create_time": 1592282639
}
]
}
Example of a batch document query response
{
"code": 0,
"msg": "",
"data": [
{
"id": 1,
"archive_id": 1,
"sku_id": 0,
"user_id": 1,
"create_time": 1592282639
},
{
"id": 3,
"archive_id": 3,
"sku_id": 0,
"user_id": 1,
"create_time": 1592285000
}
]
}
Example of an un收藏 response
{
"code": 0,
"msg": "",
"data": []
}
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 |