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

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

这是微信示例:
在这里插入图片描述

在检查自己代码发现并无错误时,修改 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<String, Object> map = new HashMap<String, Object>();
		map.put("touser", open_id); //推送用户openid
		map.put("template_id", "111"); //指定模版ID
		
		Map<String, Object> xcx = new HashMap<String, Object>();
		xcx.put("appid", "111");
		xcx.put("path", "pages/lunar/index");
		map.put("miniprogram", xcx);  //点击模版跳转地址
		
		Map<String, Object> data_map =new HashMap<String, Object>();
		Map<String, Object> first = new HashMap<String, Object>();
		first.put("value", "您好,你有一条信息");
		first.put("color", "#000000");
		Map<String, Object> keynote1 = new HashMap<String, Object>();
		keynote1.put("value", "123");
		keynote1.put("color", "#000000");
		Map<String, Object> keynote2 = new HashMap<String, Object>();
		keynote2.put("value", "2020-09-18");
		keynote2.put("color", "#000000");
		Map<String, Object> remark = new HashMap<String, Object>();
		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) {
		
	}

}
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值