mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-04-23 23:58:44 +08:00
Improve 'templateSend' method to check the response code to see if it's successful or not.
This commit is contained in:
parent
9363a67538
commit
23c96d9076
@ -507,7 +507,10 @@ public class WxMpServiceImpl implements WxMpService {
|
||||
String url = "https://api.weixin.qq.com/cgi-bin/message/template/send";
|
||||
String responseContent = execute(new SimplePostRequestExecutor(), url, templateMessage.toJson());
|
||||
JsonElement tmpJsonElement = Streams.parse(new JsonReader(new StringReader(responseContent)));
|
||||
return tmpJsonElement.getAsJsonObject().get("msgid").getAsString();
|
||||
final JsonObject jsonObject = tmpJsonElement.getAsJsonObject();
|
||||
if (jsonObject.get("errcode").getAsInt() == 0)
|
||||
return jsonObject.get("msgid").getAsString();
|
||||
throw new WxErrorException(WxError.fromJson(responseContent));
|
||||
}
|
||||
|
||||
public WxMpSemanticQueryResult semanticQuery(WxMpSemanticQuery semanticQuery) throws WxErrorException {
|
||||
|
Loading…
Reference in New Issue
Block a user