公众号推送模板消息,跳转小程序报错invalid weapp pagepath

公众号推送模板消息,跳转小程序报错invalid weapp pagepath

这是微信示例:
公众号推送模板消息,跳转小程序报错invalid weapp pagepath_第1张图片

在检查自己代码发现并无错误时,修改 miniprogram中参数pagepath改为path即发送模板消息成功,特此记录。

/以下是自己的代码片段/
public static void main(String[] args) {

	try {
		//获取access_token
		String result2 = HttpUtils.sendGet("https://api.weixin.qq.com/cgi-bin/token","grant_type=client_credential&appid="+WechatConfig.appidByGzh+"&secret="+WechatConfig.appsecretByGzh);
		System.out.println(result2);
		//解析请求
		String access_token=JSON.parseObject(result2).get("access_token").toString();
		String open_id="推送用户";
		
		
		String	regUser = "http://wxdemo.xxxx.com/wxdevices/bodycompositionmain?openId="+open_id;
		String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+access_token;
		Map map = new HashMap();
		map.put("touser", open_id); //推送用户openid
		map.put("template_id", "111"); //指定模版ID
		
		Map xcx = new HashMap();
		xcx.put("appid", "111");
		xcx.put("path", "pages/lunar/index");
		map.put("miniprogram", xcx);  //点击模版跳转地址
		
		Map data_map =new HashMap();
		Map first = new HashMap();
		first.put("value", "您好,你有一条信息");
		first.put("color", "#000000");
		Map keynote1 = new HashMap();
		keynote1.put("value", "123");
		keynote1.put("color", "#000000");
		Map keynote2 = new HashMap();
		keynote2.put("value", "2020-09-18");
		keynote2.put("color", "#000000");
		Map remark = new HashMap();
		remark.put("value", "点击查看详情");
		remark.put("color", "#000000");
		data_map.put("first", first);
		data_map.put("keyword1", keynote1);
		data_map.put("keyword2", keynote2);
		data_map.put("remark", remark);
		map.put("data", data_map);
		JSONObject json = new JSONObject(map);
		String result = HttpUtils.sendPost(url, json.toString());
		System.out.println(result);
		JSONObject json_arr = JSONObject.parseObject(result);
		String isOk = String.valueOf(json_arr.get("errmsg"));
		if(isOk.equals("ok")){
			System.out.println("推送成功 , ");
		}else{
			System.out.println("推送失败 , ");
		}
	} catch (Exception e) {
		
	}

}

你可能感兴趣的:(微信开发,java,小程序,经验分享)