# Group messages based on hashtags
Interface should be called on the server side, not in the front end (Weixin Mini Program, web pages, APP, etc.) directly called, specific reference interface call guide
Interface name: sendAll
This interface is used to group messages based on tags
# Original validation will be performed before the text message is grouped
When a developer calls the grouping interface for the grouping of graphic messages, WeChat compares the articles that the developer prepared to group with those in the public platform original library. The results are divided into the following:
- If you are currently preparing to post a group post, you can post a post in a group if you fail to find an article in the original library.
- If you are currently preparing a group post and have hit an article in the original library, then:
- If the original author allows the article to be reproduced, you can post it in groups. When a group post is automatically replaced with the original style, the article is automatically endorsed as a reprint and the source is displayed. If you want to modify the original content or style, or do not show the reprint source when the mass, you can contact the original author and obtain authorization to send the mass.
- If the original author prohibits the reproduction of the article, it cannot be grouped.If you wish to reprint this article, you can contact the original Official Account author and obtain authorization to send it in groups.
The group messaging interface adds a new send_ignore_reprint parameter (default 0). Developers can set the send_ignore-reprint parameter of the group messagING interface to specify whether to continue the group when the article is determined to be republished.
- When the send_ignore_reprint parameter is set to 1, if the article is determined to be reproduced, and the original text is allowed to be reproduced, the group operation will continue.
- When the send_ignore_reprint parameter is set to 0, if the article is determined to be reproduced, the group operation will stop.
# API Group Security Protection
For users who open API group protection, after sending all users, you need to wait for the administrator to confirm, if the administrator refuses or does not confirm within 30 minutes, the group will fail. Users can turn off the API group protection function in "Settings - Security Center - Risk Operation Protection."
# 1. How to call
# HTTPS calls
POST https://api.weixin.qq.com/cgi-bin/message/mass/sendall?access_token=ACCESS_TOKEN
# Cloud Calls
- This interface does not support cloud calls
# Third party invocation
This interface supports Third Party Platform generation business call.
The permission set id to which the interface belongs is: 7
When a service provider is authorized by one of the permissions set, it can call on behalf of the merchant by using authorizer_access_token , which can be viewed in the third-party call documentation.
# 2. Request parameters
# Query parametersQuery String parameters
Parameter Name | type | Required to fill in | Introductions |
---|---|---|---|
access_token | string | yes | Interface invocation credentials, using access_token , authorizer_access_token |
# Request BodyRequest Payload
Parameter Name | type | Required to fill in | Introductions |
---|---|---|---|
filter | object | yes | Used to set the recipient of a text message |
msgtype | string | yes | Group message type, text message for mpnews, text message for text, voice for voice, music for music, picture for image, video for video, card voucher for wxcard |
mpnews | object | no | Graphic message |
text | object | no | Text Message |
voice | object | no | Voice Messages |
images | object | no | Photo message |
mpvideo | object | no | Video Messages |
wxcard | object | no | Card Messages |
clientmsgid | string | no | Developer side group msgid, the length limit of 32 bytes, if not filled in, the background default to group range and group content summary value as clientmsgid |
# Body.filterObject Payload
Used to set the recipient of a text message
Parameter Name | type | Required to fill in | Introductions |
---|---|---|---|
is_to_all | string | no | Used to set whether to send to all users, the value is true or false, select true The message is sent to all users, select false according to the tag_id sent to the specified group of users |
tag_id | string | no | The tag_id of the tag sent to the group, see the user grouping interface in user management, if is_to_all value is true, you can not fill in the tag_id |
# Body.mpnewsObject Payload
Graphic message
Parameter Name | type | Required to fill in | Introductions |
---|---|---|---|
media_id | string | no | Media_id for a group message |
# Body.textObject Payload
Text Message
Parameter Name | type | Required to fill in | Introductions |
---|---|---|---|
content | string | no | Text content |
# Body.voiceObject Payload
Voice Messages
Parameter Name | type | Required to fill in | Introductions |
---|---|---|---|
media_id | string | no | Media_id for a group message |
# Body.imagesObject Payload
Photo message
Parameter Name | type | Required to fill in | Introductions |
---|---|---|---|
media_ids | array | no | Media_id list of graphic messages for mass posting |
recommend | string | no | Recommendations |
title | string | no | title |
need_open_comment | number | no | Open Comment (1 - Open, 0 - Close) |
only_fans_can_comment | number | no | Only fans can comment (1-on, 0-off) |
# Body.mpvideoObject Payload
Video Messages
Parameter Name | type | Required to fill in | Introductions |
---|---|---|---|
media_id | string | no | Media_id for a group message |
# Body.wxcardObject Payload
Card Messages
Parameter Name | type | Required to fill in | Introductions |
---|---|---|---|
card_id | string | no | Voucher ID |
# 3. Return Parameters
# Response Payload
Parameter Name | type | Introductions |
---|---|---|
type | string | Media types, respectively, there are pictures (image), voice (voice), video (video) and thumbnail (thumb), the number of news, that is, graphic message |
errcode | number | Error code |
errmsg | string | Error message |
msg_id | number | The ID of the message sending task |
msg_data_id | number | The data ID of the message, which appears only when a group text message is sent. The data that can be used to obtain the corresponding graph message in a graph analysis data interface is the first half of the msgid field in the graph analysis datainterface, as described in more detail in the msgID field in the diagram analysis data interface. |
# 4. Note
- The media_id of the graphic message is obtained by uploading the graphic material [ ](() or by creating a new draft ](() interface.
- If the media_id is obtained through the "Draft Box / New Draft" interface, then the media_id will be invalidated after the success of the group, and the background draft will be automatically deleted.
- Overseas WeChat Official Account Only mpnews messages are supported.
- When the return is successful, it means that the group task has been submitted successfully, and it does not mean that the group is finished at this time, so it is still possible that there are unusual circumstances during subsequent dispatch that cause the user to not receive the message, such as the message is sometimes audited, the server is unstable, etc. In addition, it generally takes a long time for a group task to be fully sent, so please be patient.
# Avoid sending repeatedly
Developers can actively set the clientmsgid parameter when calling the group interface to avoid repeated push.
When sending a group, WeChat background will check the group records within 24 hours,If a message already exists on the clientmsgid, this message request is rejected, returning the existing message msgid, and the developer can call the "query message sending status" interface to see the status of the message.
# Event Push Group Results
Since a group task may not be completed until a certain time after it has been submitted,Thus, when the queue interface is called, it only gives a hint of whether the queue task has been successfully submitted, and if the queue job has been submitted successfully, the event is pushed to the developer URL (callback URL) that the developer filled out on the public platform at the end of the queue.
It should be noted that since the complete completion of the cluster task takes a long time, the cluster results will be pushed when the cluster tasks are about to be completed, and the pushed number data will be somewhat inaccurate from the actual situation
The XML structure of the push is as follows (when sent successfully):
<xml>
<ToUserName><![CDATA[gh_4d00ed8d6399]]></ToUserName>
<FromUserName><![CDATA[oV5CrjpxgaGXNHIQigzNlgLTnwic]]></FromUserName>
<CreateTime>1481013459</CreateTime>
<MsgType><![CDATA[event]]></MsgType>
<Event><![CDATA[MASSSENDJOBFINISH]]></Event>
<MsgID>1000001625</MsgID>
<Status><![CDATA[err(30003)]]></Status>
<TotalCount>0</TotalCount>
<FilterCount>0</FilterCount>
<SentCount>0</SentCount>
<ErrorCount>0</ErrorCount>
<CopyrightCheckResult>
<Count>2</Count>
<ResultList>
<item>
<ArticleIdx>1</ArticleIdx>
<UserDeclareState>0</UserDeclareState>
<AuditState>2</AuditState>
<OriginalArticleUrl><![CDATA[Url_1]]></OriginalArticleUrl>
<OriginalArticleType>1</OriginalArticleType>
<CanReprint>1</CanReprint>
<NeedReplaceContent>1</NeedReplaceContent>
<NeedShowReprintSource>1</NeedShowReprintSource>
</item>
<item>
<ArticleIdx>2</ArticleIdx>
<UserDeclareState>0</UserDeclareState>
<AuditState>2</AuditState>
<OriginalArticleUrl><![CDATA[Url_2]]></OriginalArticleUrl>
<OriginalArticleType>1</OriginalArticleType>
<CanReprint>1</CanReprint>
<NeedReplaceContent>1</NeedReplaceContent>
<NeedShowReprintSource>1</NeedShowReprintSource>
</item>
</ResultList>
<CheckState>2</CheckState>
</CopyrightCheckResult>
<ArticleUrlResult>
<Count>1</Count>
<ResultList>
<item>
<ArticleIdx>1</ArticleIdx>
<ArticleUrl><![CDATA[Url]]></ArticleUrl>
</item>
</ResultList>
</ArticleUrlResult>
</xml>
Parameter explaination
parameter | Introductions |
---|---|
ToUserName | Official Account of WeChat |
FromUserName | Official Account The WeChat number for mphelper |
CreateTime | The timestamp of the time created |
MsgType | Message type, in this case event |
Event | Event information, here for MASSSENDJOBFINISH |
MsgID | Group message ID |
Status | The result of a group message is "send success" or "send fail" or "err (num)."However, when "send success," it may also cause a small number of users to receive failure due to user rejection of Official Account messages, system errors and other reasons.Err (num) is the specific reason for the failure of the audit. Possible scenarios are as follows: err (10001): suspected advertising, err (20001): suspected politics, Err (20004): suspected of social, err (20002): suspected of pornography, err (20006): suspected of criminal offences, err (20008): suspected of fraud, Err (20013): suspected copyright, err (22000): suspected mutual promotion (mutual promotion), err (21000): suspects other, err (9315): unregulated use of public maps, err (30001): a system error in original validation and the user chooses not to syndicate, Err (30002): Original validation was determined not to group, err (30003): Original verification was determined to be republished and the user chose not to group after being adjudged republished, err (40001): Administrator refused, err (4002): Administrator was unresponsive for 30 minutes, timeout |
TotalCount | Number of fans under tag_id; Or the number of fans in touser |
FilterCount | The number of fans ready to send after filtering (filtering refers to specific regions, gender filtering, user settings reject filtering, users receive more than 4 filters), generally FilterCount is about equal to SentCount + ErrorCount |
SentCount | Number of successful followers sent |
ErrorCount | Number of followers who failed to send |
ResultList | Results of individual textual validation |
ArticleIdx | The serial number of group posts, starting with 1 |
UserDeclareState | The user declares the status of the article. 0 indicates that the user did not declare the original; 1 indicates a user's declaration of originality; 2 means a user's declaration of reproduction |
AuditState | The state of the system validation. 0 indicates that the original is not yet validated; 1 indicates validation in original; 11 means that the original verification has been approved; Others indicate that the original validation failed. |
OriginalArticleUrl | Similar original URL |
OriginalArticleType | Similar to the type of original text. 1 represents the original text; 2 means that historical text is not original; 3 means news category; 4 represents a hack class |
CanReprint | Is it possible to reproduce it? |
NeedReplaceContent | Do you need to replace the original text content? |
NeedShowReprintSource | Do I need to indicate the source of the reproduction? |
CheckState | The overall validation results. 1-Not convicted of reprint, can be grouped, 2- convicted of reproducing, can be groupsed, 3- convicted of recidivism, cannot be grouped |
ArticleUrl | The URL of the group post |
# 5. Code examples
# 5.1 Graphic message
Example Requests
{
"filter":{
"is_to_all":false,
"tag_id":2
},
"mpnews":{
"media_id":"123dsdajkasd231jhksad"
},
"msgtype":"mpnews",
"send_ignore_reprint":0
}
Return an example
{
"errcode":0,
"errmsg":"send job submission success",
"msg_id":34182,
"msg_data_id": 206227730
}
# 5.2 Text Message
Example Requests
{
"filter":{
"is_to_all":false,
"tag_id":2
},
"text":{
"content":"CONTENT"
},
"msgtype":"text"
}
Return an example
{
"errcode":0,
"errmsg":"send job submission success",
"msg_id":34182,
"msg_data_id": 206227730
}
# 5.3 Voice Messages
Example Requests
{
"filter":{
"is_to_all":false,
"tag_id":2
},
"voice":{
"media_id":"123dsdajkasd231jhksad"
},
"msgtype":"voice"
}
Return an example
{
"errcode":0,
"errmsg":"send job submission success",
"msg_id":34182,
"msg_data_id": 206227730
}
# 5.4 Photo message
Example Requests
{
"filter":{
"is_to_all":false,
"tag_id":2
},
"images": {
"media_ids": [
"aaa",
"bbb",
"ccc"
],
"recommend": "xxx",
"title": "yyy",
"need_open_comment": 1,
"only_fans_can_comment": 0
},
"msgtype":"image"
}
Return an example
{
"errcode":0,
"errmsg":"send job submission success",
"msg_id":34182,
"msg_data_id": 206227730
}
# 5.5 Video Messages
Example Requests
{
"filter":{
"is_to_all":false,
"tag_id":2
},
"mpvideo":{
"media_id":"IhdaAQXuvJtGzwwc0abfXnzeezfO0NgPK6AQYShD8RQYMTtfzbLdBIQkQziv2XJc"
},
"msgtype":"mpvideo"
}
Return an example
{
"errcode":0,
"errmsg":"send job submission success",
"msg_id":34182,
"msg_data_id": 206227730
}
# 5.6 Card Messages
Example Requests
{
"filter":{
"is_to_all":false,
"tag_id":"2"
},
"wxcard":{
"card_id":"123dsdajkasd231jhksad"
},
"msgtype":"wxcard"
}
Return an example
{
"errcode":0,
"errmsg":"send job submission success",
"msg_id":34182,
"msg_data_id": 206227730
}
# 6. Error code
The following is a list of error codes for this interface, other error codes can refer to General error codes
Error code | Error Description | Solutions |
---|---|---|
41040 | no | Does not meet the requirement to declare the originality of the text |
45062 | has agreement ad. please use mp.weixin.qq.com | Received advertising, does not support API group |
45065 | clientmsgid exist | A group record already exists for the same clientmsgid, returns the msgid with the existing group task in the data |
45066 | same clientmsgid retry too fast | The same clientmsgid retry too fast, please retry at 1 minute intervals |
45067 | clientmsgid size out of limit | Clientmsgid Length Exceeds Limit |
48021 | no | This draft was last saved automatically by the system and is not allowed to be grouped |
89504 | Group distribution is still in the approval process | Please wait a minute or contact the administrator to confirm |
89505 | Group messaging into the administrator confirmation process | Please wait a minute or contact the administrator to confirm |
# 7. Scope of application
Official Account | Service Account |
---|---|
Certification only | Certification only |
- Authentication only: means that only authenticated accounts are allowed to be invoked by the enterprise entity, and accounts that are not authenticated or do not support authentication cannot be invoked.
- Other account types that are not expressly stated may not be called on this interface without special instructions;