From b9cbfe2653e9b4cf343b9aa1e390f6b1e77206b9 Mon Sep 17 00:00:00 2001 From: fwq <582742538@qq.com> Date: 星期一, 23 十月 2023 19:25:33 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- src/main/java/com/hx/mp/util/MpUtil.java | 63 +++++++++++++++++++++++++++++++ 1 files changed, 63 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 cad3924..2dbc9cc 100644 --- a/src/main/java/com/hx/mp/util/MpUtil.java +++ b/src/main/java/com/hx/mp/util/MpUtil.java @@ -1,5 +1,6 @@ package com.hx.mp.util; +import com.hx.util.HttpMethodUtil; import com.hx.util.StringUtils; import net.sf.json.JSONException; import net.sf.json.JSONObject; @@ -14,6 +15,8 @@ import java.sql.Timestamp; import java.text.MessageFormat; import java.util.Date; +import java.util.HashMap; +import java.util.Map; /** * 寰俊灏忕▼搴忓伐鍏风被 @@ -354,4 +357,64 @@ return qrStr; } + /** + * 鑾峰彇灏忕▼搴忛摼鎺� + * @param token 灏忕▼搴弔oken + * @param path 灏忕▼搴忛〉闈㈣矾寰� + * @param query 浼犲�煎弬鏁� + * @param env_version + * @return 瑕佹墦寮�鐨勫皬绋嬪簭鐗堟湰銆傛寮忕増涓� "release"锛屼綋楠岀増涓�"trial"锛屽紑鍙戠増涓�"develop"锛屼粎鍦ㄥ井淇″鎵撳紑鏃剁敓鏁� + */ + public static String getAooLetUrl(String token, String path, String query, String env_version) { + Map<String, Object> map = new HashMap<>(); + map.put("access_token", token); + JSONObject data = new JSONObject(); + data.put("path", path); + data.put("query", query); + 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