use of me.chanjar.weixin.common.util.http.SimplePostRequestExecutor in project weixin-java-tools by chanjarster.
the class WxMpServiceImpl method massNewsUpload.
public WxMpMassUploadResult massNewsUpload(WxMpMassNews news) throws WxErrorException {
String url = "https://api.weixin.qq.com/cgi-bin/media/uploadnews";
String responseContent = execute(new SimplePostRequestExecutor(), url, news.toJson());
return WxMpMassUploadResult.fromJson(responseContent);
}
use of me.chanjar.weixin.common.util.http.SimplePostRequestExecutor in project weixin-java-tools by chanjarster.
the class WxMpServiceImpl method qrCodeCreateLastTicket.
public WxMpQrCodeTicket qrCodeCreateLastTicket(String scene_str) throws WxErrorException {
String url = "https://api.weixin.qq.com/cgi-bin/qrcode/create";
JsonObject json = new JsonObject();
json.addProperty("action_name", "QR_LIMIT_STR_SCENE");
JsonObject actionInfo = new JsonObject();
JsonObject scene = new JsonObject();
scene.addProperty("scene_str", scene_str);
actionInfo.add("scene", scene);
json.add("action_info", actionInfo);
String responseContent = execute(new SimplePostRequestExecutor(), url, json.toString());
return WxMpQrCodeTicket.fromJson(responseContent);
}
use of me.chanjar.weixin.common.util.http.SimplePostRequestExecutor in project weixin-java-tools by chanjarster.
the class WxMpServiceImpl method qrCodeCreateTmpTicket.
public WxMpQrCodeTicket qrCodeCreateTmpTicket(int scene_id, Integer expire_seconds) throws WxErrorException {
String url = "https://api.weixin.qq.com/cgi-bin/qrcode/create";
JsonObject json = new JsonObject();
json.addProperty("action_name", "QR_SCENE");
if (expire_seconds != null) {
json.addProperty("expire_seconds", expire_seconds);
}
JsonObject actionInfo = new JsonObject();
JsonObject scene = new JsonObject();
scene.addProperty("scene_id", scene_id);
actionInfo.add("scene", scene);
json.add("action_info", actionInfo);
String responseContent = execute(new SimplePostRequestExecutor(), url, json.toString());
return WxMpQrCodeTicket.fromJson(responseContent);
}
use of me.chanjar.weixin.common.util.http.SimplePostRequestExecutor in project weixin-java-tools by chanjarster.
the class WxMpServiceImpl method shortUrl.
public String shortUrl(String long_url) throws WxErrorException {
String url = "https://api.weixin.qq.com/cgi-bin/shorturl";
JsonObject o = new JsonObject();
o.addProperty("action", "long2short");
o.addProperty("long_url", long_url);
String responseContent = execute(new SimplePostRequestExecutor(), url, o.toString());
JsonElement tmpJsonElement = Streams.parse(new JsonReader(new StringReader(responseContent)));
return tmpJsonElement.getAsJsonObject().get("short_url").getAsString();
}
use of me.chanjar.weixin.common.util.http.SimplePostRequestExecutor in project weixin-java-tools by chanjarster.
the class WxCpServiceImpl method departCreate.
public Integer departCreate(WxCpDepart depart) throws WxErrorException {
String url = "https://qyapi.weixin.qq.com/cgi-bin/department/create";
String responseContent = execute(new SimplePostRequestExecutor(), url, depart.toJson());
JsonElement tmpJsonElement = Streams.parse(new JsonReader(new StringReader(responseContent)));
return GsonHelper.getAsInteger(tmpJsonElement.getAsJsonObject().get("id"));
}
Aggregations