In order to make it easy for the Official Account developers and developers of third-party platforms for Official Accounts to flexibly use the article comment feature, related APIs for this feature are released.

1. Managing Comments

When creating new media (and provided that your Official Account is authorized to use the comment feature), you can specify the media_id to enable the comment feature for your broadcast, and specify the comment scope of the media_id (everyone can leave comments, or only the Official Account followers can leave comments).

1.1 Adding Permanent Media (The original API has been changed)

API Request Format

https request method: POST
https://api.weixin.qq.com/cgi-bin/material/add_news?access_token=ACCESS_TOKEN

Parameters

Parameter Required Type Description
title Yes string The Title
thumb_media_id Yes string The media ID for the cover image of articles (it must be a permanent mediaID)
authod Yes string The author
digest Yes string The summary of an article. Only the single article has a summary. For multiple articles, it is empty.
show_cover_pic Yes string Indicates whether to display the cover. 0 is false, indicating not to display; 1 is true, indicating to display.
content Yes string Detailed contents of articles, which supports HTML tags. It must be less than 20,000 characters and 1 MB in size. JS-related content will be removed.
content_source_url Yes string The original page URL of an article. The URL to be redirected to after tapping Read More.
need_open_comment (new field) No Uint32 Indicates whether to enable comment. 0 indicates disabled and 1 indicates enabled.
only_fans_can_comment (new field) No Uint32 Indicates whether only followers can comment. 0 indicates everyone can comment and 1 indicates only followers can comment.

Calling Example

{
    "articles":[{
    "title": TITLE,
    "thumb_media_id": THUMB_MEDIA_ID,
    "author": AUTHOR, "digest" : DIGEST,
    "show_cover_pic": SHOW_COVER_PIC(0/1),
    "content" : CONTENT,
    "content_source_url": CONTENT_SOURCE_URL,
    "need_open_comment" : NEED_OPEN_COMMENT(0/1),
    "only_fans_can_comment" : ONLY_FANS_CAN_COMMENT(0/1) }]
    //If multiple articles are added, there should also be more segments of structure information here for these articles. 8 segments at most. 
} 

Response (in JSON format)

{ "media_id" : MEDIA_ID }

New error code (in JSON format)

{ "errcode" : 88000,  "errmsg" : "without comment privilege"   //No permission to leave comments } 

1.2 Obtaining Permanent Media (The original API has been changed)

API Request Format

https request method: POST
https://api.weixin.qq.com/cgi-bin/material/get_material?access_token=ACCESS_TOKEN

Response Description

New response fields need_open_comment and only_fans_can_comment

1.3 Modifying Permanent Articles (The original API has been changed)

API Request Format

https request method: POST
https://api.weixin.qq.com/cgi-bin/material/update_news?access_token=ACCESS_TOKEN

New parameters need_open_comment and only_fans_can_comment

1.4 Obtaining Media List (The original API has been changed)

API Request Format

https request method: POST
https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token=ACCESS_TOKEN

New parameters need_open_comment and only_fans_can_comment

2. Managing Comment Data

2.1 Enabling Comment for Broadcasted Articles (New API)

API Request Format

https request method: POST
https://api.weixin.qq.com/cgi-bin/comment/open?access_token=ACCESS_TOKEN

Parameters

Parameter Required Type Description
msg_data_id Yes Uint32 The msg_data_id returned from broadcast
index No Uint32 Indicates which one to begin with when there are multiple articles. Articles are ordered starting from 0. If this parameter is not specified, it will begin with the first article for the msg_data_id

Calling Example

{ "msg_data_id" : MSG_DATA_ID, "index" : INDEX }

Response (in JSON format)

{ "errcode": ERRCODE, "errmsg" : ERRMSG } 

Error code definition

{ 
    "errcode" : 45009,
    "errmsg" : "reach max api daily quota limit"
    //No remaining calls 
  }
 { 
    "errcode" : 88000,  
    "errmsg" : "without comment privilege"
    //No permission to leave comments
  }
 { 
    "errcode" : 88001, 
    "errmsg" : "msg_data is not exists" 
    //The article does not exist.
   }
 { 
    "errcode": 88002, 
     "errmsg" : "the article is limit for safety"
     //The article contains sensitive information. 
}

2.2 Disabling Comment for Broadcasted Articles (New API)

API Request Format

https request method: POST
https://api.weixin.qq.com/cgi-bin/comment/close?access_token=ACCESS_TOKEN

Parameters

Parameter Required Type Description
msg_data_id Yes Uint32 The msg_data_id returned from broadcast
index No Uint32 Indicates which one to begin with when there are multiple articles. Articles are ordered starting from 0. If this parameter is not specified, it will begin with the first article for the msg_data_id

Calling Example

{ "msg_data_id" : MSG_DATA_ID, "index" : INDEX, }

Response (in JSON format)

{ "errcode": ERRCODE, "errmsg" : ERRMSG } 

2.3 Viewing Comment Data for Specified Articles (New API)

API Request Format

https request method: POST
https://api.weixin.qq.com/cgi-bin/comment/list?access_token=ACCESS_TOKEN

Parameters

Parameter Required Type Description
msg_data_id Yes Uint32 The msg_data_id returned from broadcast
index No Uint32 Indicates which one to begin with when there are multiple articles. Articles are ordered starting from 0. If this parameter is not specified, it will return the first article for the msg_data_id
begin Yes Uint32 The start position
count Yes Uint32 Number of articles to retrieve (a number equal to or greater than 50 will be denied)
type Yes Uint32 type=0: General comments & featured comments; type=1: General comments; type=2: Featured comments

Calling Example

{ "msg_data_id" : MSG_DATA_ID, "index" : INDEX, "begin": BEGIN, "count": COUNT, "type" : TYPE } 

Response (in JSON format)

{ 
    "errcode": 0, 
    "errmsg" : "ok", 
    "total": TOTAL          //Total number. Not the size around of the comment.
    "comment": [{ 
	    "user_comment_id" : USER_COMMENT_ID  	//User comment ID 
		"openid ": OPENID        				//openid 
		"create_time ": CREATE_TIME    			//Comment time 
		"content" : CONTENT            			//Comment content 
		"comment_type ": IS_ELECTED   			//Indicates whether it is a featured comment. 1 is true, indicating a featured comment. 0 represents not a featured comment.
		"reply ": { 
				"content ": CONTENT       		//Author's reply
				"create_time" : CREATE_TIME  	//Time of author's reply 
			} 
		}] 
}

Error code definition

{ "errcode" : 45009, "errmsg" : "reach max api daily quota limit"                  //No remaining calls }
 { "errcode" : 88000,  "errmsg" : "open comment without comment privilege" //No permission to leave comments }
 { "errcode" : 88001, "errmsg" : "msg_data is not exists"                                   //The article does not exist. }
 { "errcode" : 88010, "errmsg" : "count range error. cout <= 0 or count > 50" //The obtained number of comments is invalid } 

2.4 Marking Featured Comments (New API)

API Request Format

https request method: POST
https://api.weixin.qq.com/cgi-bin/comment/markelect?access_token=ACCESS_TOKEN

Parameters

Parameter Required Type Description
msg_data_id Yes Uint32 The msg_data_id returned from broadcast
index No Uint32 Indicates which one to begin with when there are multiple articles. Articles are ordered starting from 0. If this parameter is not specified, it will begin with the first article for the msg_data_id
" user_comment_id " Uint32 User comment ID

Calling Example

{ "msg_data_id" : MSG_DATA_ID, "index": INDEX, "user_comment_id": COMMENT_ID, } 

Response (in JSON format)

 { "errcode": ERRCODE, "errmsg" : ERRMSG } 

Error code definition

 { "errcode" : 45009, "errmsg" : "reach max api daily quota limit"                  //No remaining calls }
 { "errcode" : 88000,  "errmsg" : "open comment without comment privilege" //No permission to leave comments }
 { "errcode" : 88001, "errmsg" : "msg_data is not exists"                                  //The article does not exist. }
 { "errcode" : 88003, "errmsg" : "elected comment upper limit"                      //The number of featured comments has reached the limit. }
 { "errcode" : 88004, "errmsg" : "comment was deleted by user"                     //This comment has been deleted by the user and cannot be set as a featured comment. }
 { "errcode" : 88008, "errmsg" : "comment is not exists"                                  //The comment does not exist. } 

2.5 Canceling Featured Comments

API Request Format

https request method: POST
https://api.weixin.qq.com/cgi-bin/comment/unmarkelect?access_token=ACCESS_TOKEN

Parameters

Parameter Required Type Description
msg_data_id Yes Uint32 The msg_data_id returned from broadcast
index No Uint32 Indicates which one to begin with when there are multiple articles. Articles are ordered starting from 0. If this parameter is not specified, it will begin with the first article for the msg_data_id
user_comment_id Yes Uint32 User comment ID

Calling Example

{ "msg_data_id" : MSG_DATA_ID, "index": INDEX, "user_comment_id": COMMENT_ID, } 

Response (in JSON format)

{ "errcode": ERRCODE, "errmsg" : ERRMSG } 

Error code definition

{ "errcode" : 45009, "errmsg" : "reach max api daily quota limit"                  //No remaining calls }
{ "errcode" : 88000,  "errmsg" : "open comment without comment privilege" //No permission to leave comments }
{ "errcode" : 88001, "errmsg" : "msg_data is not exists"                                          //The article does not exist. }
{ "errcode" : 88008, "errmsg" : "comment is not exists"                                          //The comment does not exist. } 

2.6 Deleting Comments (New API)

API Request Format

https request method: POST
https://api.weixin.qq.com/cgi-bin/comment/delete?access_token=ACCESS_TOKEN

Parameters

Parameter Required Type Description
msg_data_id Yes Uint32 The msg_data_id returned from broadcast
index No Uint32 Indicates which one to begin with when there are multiple articles. Articles are ordered starting from 0. If this parameter is not specified, it will begin with the first article for the msg_data_id
user_comment_id Yes Uint32 Comment ID

Calling Example

{ "msg_data_id" : MSG_DATA_ID, "index"        : INDEX, "user_comment_id": COMMENT_ID, }

Response (in JSON format)

 {"errcode": ERRCODE, "errmsg" : ERRMSG } 

Error code definition

{ "errcode" : 45009, "errmsg" : "reach max api daily quota limit"                  //No remaining calls }
 { "errcode" : 88000,  "errmsg" : "open comment without comment privilege" //No permission to leave comments }
 { "errcode" : 88001, "errmsg" : "msg_data is not exists"                                          //The article does not exist. } 
 { "errcode" : 88008, "errmsg" : "comment is not exists"                                          //The comment does not exist. } 

2.7 Replying to Comments (New API)

API Request Format

https request method: POST
https://api.weixin.qq.com/cgi-bin/comment/reply/add?access_token=ACCESS_TOKEN

Parameters

Parameter Required Type Description
msg_data_id Yes Uint32 The msg_data_id returned from broadcast
index No Uint32 Indicates which one to begin with when there are multiple articles. Articles are ordered starting from 0. If this parameter is not specified, it will begin with the first article for the msg_data_id
user_comment_id Yes Uint32 Comment ID
content Yes string Reply content

Calling Example

{ "msg_data_id" : MSG_DATA_ID, "index"        : INDEX, "user_comment_id": COMMENT_ID, "content": CONTENT }

Response (in JSON format)

{ "errcode": ERRCODE, "errmsg" : ERRMSG } 

Error code definition

{ "errcode" : 45009, "errmsg" : "reach max api daily quota limit"                  //No remaining calls }
 { "errcode" : 88000,  "errmsg" : "open comment without comment privilege" //No permission to leave comments } 
 { "errcode" : 88001, "errmsg" : "msg_data is not exists"                              //The article does not exist. } 
 { "errcode" : 88005, "errmsg" : "already reply"                                            //The comment has already been replied to. } 
 { "errcode" : 88007, "errmsg" : "reply content beyond max len or content len is zero"//The reply content exceeds the limit or its length is 0. }
 { "errcode" : 88008, "errmsg" : "comment is not exists"                            //The comment does not exist. } 

2.8 Deleting Replies (New API)

API Request Format

https request method: POST
https://api.weixin.qq.com/cgi-bin/comment/reply/delete?access_token=ACCESS_TOKEN

Parameters

Parameter Required Type Description
msg_data_id Yes Uint32 The msg_data_id returned from broadcast
index No Uint32 Indicates which one to begin with when there are multiple articles. Articles are ordered starting from 0. If this parameter is not specified, it will begin with the first article for the msg_data_id
user_comment_id Yes Uint32 Comment ID

Calling Example

{ "msg_data_id" : MSG_DATA_ID, "index"        : INDEX, "user_comment_id": COMMENT_ID, }

Response (in JSON format)

{ "errcode": ERRCODE, "errmsg" : ERRMSG }

Error code definition

{ "errcode" : 45009, "errmsg" : "reach max api daily quota limit"                     //No remaining calls }  
{ "errcode" : 88000,  "errmsg" : "open comment without comment privilege" //No permission to leave comments }  
 { "errcode" : 88001, "errmsg" : "msg_data is not exists"                                   //The article does not exist. }
 { "errcode" : 88008, "errmsg" : "comment is not exists"                                   //The comment does not exist. }
 { "errcode" : 87009, "errmsg" : "reply is not exists"                                         //The reply does not exist. }