From 1821a09470849995a07825d1ae2ae37b30ca82e8 Mon Sep 17 00:00:00 2001 From: fhx <308050795@qq.com> Date: 星期一, 06 十一月 2023 17:27:22 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- src/main/java/com/hx/mp/util/MpUtil.java | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 43 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/hx/mp/util/MpUtil.java b/src/main/java/com/hx/mp/util/MpUtil.java index 1c64291..2dbc9cc 100644 --- a/src/main/java/com/hx/mp/util/MpUtil.java +++ b/src/main/java/com/hx/mp/util/MpUtil.java @@ -374,4 +374,47 @@ data.put("env_version", env_version); return HttpMethodUtil.HttpURLUtilJson("https://api.weixin.qq.com/wxa/generate_urllink", data.toString(), map, null, "POST"); } + + + /** + * 鍏紬鍙峰彂閫佸皬绋嬪簭鍗$墖瀹㈡埛娑堟伅 + * @param access_token access_token + * @param toUser 鐢ㄦ埛openid + * @param title 鏍囬 + * @param appid 灏忕▼搴廰ppid + * @param pagepath 璺宠浆椤甸潰璺緞 + * @param thumb_media_id 缂╃暐鍥�/灏忕▼搴忓崱鐗囧浘鐗囩殑濯掍綋ID锛屽皬绋嬪簭鍗$墖鍥剧墖寤鸿澶у皬涓�520*416 + * @return + */ + public static String sendMpMsg(String access_token, String toUser, String title,String appid,String pagepath,String thumb_media_id) { + String result = "fail"; + + try { + JSONObject obj = new JSONObject(); + obj.put("touser", toUser); + obj.put("msgtype", "miniprogrampage"); + + JSONObject pObj = new JSONObject(); + pObj.put("title", title); + pObj.put("appid", appid); + pObj.put("pagepath", pagepath); + pObj.put("thumb_media_id", thumb_media_id); + obj.put("miniprogrampage", pObj); + + JSONObject rObj = HttpURLUtil(URL_SEND_KF_MSG + access_token, obj.toString()); + if (rObj != null) { + if (rObj.optInt("errcode", -1) == 0) { + result = "suc"; + } else { + result = rObj.optString("errmsg"); + } + } + rObj = null; + obj = null; + } catch (Exception e) { + e.printStackTrace(); + } + + return result; + } } -- Gitblit v1.8.0