Search in sources :

Example 1 with SimplePostRequestExecutor

use of me.chanjar.weixin.common.util.http.SimplePostRequestExecutor in project weixin-java-tools by chanjarster.

the class WxMpServiceImpl method groupUpdate.

public void groupUpdate(WxMpGroup group) throws WxErrorException {
    String url = "https://api.weixin.qq.com/cgi-bin/groups/update";
    execute(new SimplePostRequestExecutor(), url, group.toJson());
}
Also used : SimplePostRequestExecutor(me.chanjar.weixin.common.util.http.SimplePostRequestExecutor)

Example 2 with SimplePostRequestExecutor

use of me.chanjar.weixin.common.util.http.SimplePostRequestExecutor in project weixin-java-tools by chanjarster.

the class WxMpServiceImpl method templateSend.

public String templateSend(WxMpTemplateMessage templateMessage) throws WxErrorException {
    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)));
    final JsonObject jsonObject = tmpJsonElement.getAsJsonObject();
    if (jsonObject.get("errcode").getAsInt() == 0)
        return jsonObject.get("msgid").getAsString();
    throw new WxErrorException(WxError.fromJson(responseContent));
}
Also used : JsonElement(com.google.gson.JsonElement) StringReader(java.io.StringReader) JsonReader(com.google.gson.stream.JsonReader) JsonObject(com.google.gson.JsonObject) SimplePostRequestExecutor(me.chanjar.weixin.common.util.http.SimplePostRequestExecutor) WxErrorException(me.chanjar.weixin.common.exception.WxErrorException)

Example 3 with SimplePostRequestExecutor

use of me.chanjar.weixin.common.util.http.SimplePostRequestExecutor in project weixin-java-tools by chanjarster.

the class WxMpServiceImpl method customMessageSend.

public void customMessageSend(WxMpCustomMessage message) throws WxErrorException {
    String url = "https://api.weixin.qq.com/cgi-bin/message/custom/send";
    execute(new SimplePostRequestExecutor(), url, message.toJson());
}
Also used : SimplePostRequestExecutor(me.chanjar.weixin.common.util.http.SimplePostRequestExecutor)

Example 4 with SimplePostRequestExecutor

use of me.chanjar.weixin.common.util.http.SimplePostRequestExecutor in project weixin-java-tools by chanjarster.

the class WxMpServiceImpl method userGetGroup.

public long userGetGroup(String openid) throws WxErrorException {
    String url = "https://api.weixin.qq.com/cgi-bin/groups/getid";
    JsonObject o = new JsonObject();
    o.addProperty("openid", openid);
    String responseContent = execute(new SimplePostRequestExecutor(), url, o.toString());
    JsonElement tmpJsonElement = Streams.parse(new JsonReader(new StringReader(responseContent)));
    return GsonHelper.getAsLong(tmpJsonElement.getAsJsonObject().get("groupid"));
}
Also used : JsonElement(com.google.gson.JsonElement) StringReader(java.io.StringReader) JsonObject(com.google.gson.JsonObject) JsonReader(com.google.gson.stream.JsonReader) SimplePostRequestExecutor(me.chanjar.weixin.common.util.http.SimplePostRequestExecutor)

Example 5 with SimplePostRequestExecutor

use of me.chanjar.weixin.common.util.http.SimplePostRequestExecutor in project weixin-java-tools by chanjarster.

the class WxMpServiceImpl method massVideoUpload.

public WxMpMassUploadResult massVideoUpload(WxMpMassVideo video) throws WxErrorException {
    String url = "http://file.api.weixin.qq.com/cgi-bin/media/uploadvideo";
    String responseContent = execute(new SimplePostRequestExecutor(), url, video.toJson());
    return WxMpMassUploadResult.fromJson(responseContent);
}
Also used : SimplePostRequestExecutor(me.chanjar.weixin.common.util.http.SimplePostRequestExecutor)

Aggregations

SimplePostRequestExecutor (me.chanjar.weixin.common.util.http.SimplePostRequestExecutor)18 JsonObject (com.google.gson.JsonObject)9 JsonElement (com.google.gson.JsonElement)4 JsonReader (com.google.gson.stream.JsonReader)4 StringReader (java.io.StringReader)4 WxErrorException (me.chanjar.weixin.common.exception.WxErrorException)1