🎨 #3142 【公众号】订阅通知下发接口返回消息id

This commit is contained in:
JTongChen 2023-10-07 21:32:21 +08:00 committed by GitHub
parent 49d73f003f
commit bf49c9a152
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -134,8 +134,9 @@ public interface WxMpSubscribeMsgService {
* </pre>
*
* @param subscribeMessage 订阅消息
* @return 下发消息id与下发结果回调的msgId对应
* @throws WxErrorException .
*/
void send(WxMpSubscribeMessage subscribeMessage) throws WxErrorException;
String send(WxMpSubscribeMessage subscribeMessage) throws WxErrorException;
}

View File

@ -103,11 +103,12 @@ public class WxMpSubscribeMsgServiceImpl implements WxMpSubscribeMsgService {
}
@Override
public void send(WxMpSubscribeMessage subscribeMessage) throws WxErrorException {
public String send(WxMpSubscribeMessage subscribeMessage) throws WxErrorException {
String responseContent = this.service.post(SEND_SUBSCRIBE_MESSAGE_URL, subscribeMessage.toJson());
JsonObject jsonObject = GsonParser.parse(responseContent);
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MP));
}
return jsonObject.get("msgid").getAsString();
}
}