Post comment interface

Allow users to post comments on specified documents, supporting general comments and reply comments features.

Points to note

  • The API uses the POST method and requires data to be submitted in application/ format
  • Provide valid document ID, username, and comment content.
  • Support publishing replies to other comments (via the parent_id parameter)
  • Comments may need to be reviewed before they are displayed (based on the status field)
  • Ensure that the domain address is correctly configured
  • There may be a comment frequency limit to prevent spamming

Request address

{域名地址}/api/comment/publish

Description:{域名地址}Replace it with your domain name, such ashttps://en.anqicms.com/api/comment/publish

Request Syntax

POST /api/comment/publish
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 Is Document ID of the comment
user_name string Is Username
content string Is Comment content
parent_id int No Referenced Comment ID

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 result content

Data Result

Field name Type Description
id int Comment ID
parent_id int Parent Comment ID
archive_id int Document ID
user_name string Comment username
user_id int Comment user ID
IP string Commenter IP
Vote count int like count
content string category content details
created_time int publish timestamp
updated_time int update timestamp
status int review status, 1 reviewed, 0 in review

Usage Example

Request example

POST /api/comment/publish HTTP/1.1
Host: www.anqicms.com
Content-Type: application/json

{
  "user_name": "anqicms",
  "content": "欢迎使用anqicms",
  "archive_id": 140
}

Response Example

{
  "code": 0,
  "data": {
    "id": 33,
    "created_time": 1662734920,
    "updated_time": 1662734920,
    "archive_id": 140,
    "user_id": 0,
    "user_name": "anqicms",
    "ip": "127.0.0.1",
    "vote_count": 0,
    "content": "欢迎使用anqicms",
    "parent_id": 0,
    "status": 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