微信文档:https://developers.weixin.qq.com/minigame/dev/guide/open-ability/message-push.html
微信后台配置,接口校验.
Map params = new HashMap<>();
params.put("grant_type", "client_credential");
params.put("appid", appId);
params.put("secret", secret);
final String wxAPIHost = "https://api.weixin.qq.com/cgi-bin/token";
String tokenResponseStr = HttpUtils.doGet(wxAPIHost, "", null, params);
1.请求发消息接口返回:{"errcode":40001,"errmsg":"invalid credential, access_token is invalid or not latest hints: [1iObxxPfe-E2eqjA!]"}
access_token已经获取到了,回复消息的时候还是说有问题,原来access_token一定要和请求地址拼接起来请求,正确方式如下:
消息发送接口地址https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=lalalalalala;
2.请求发消息接口返回:{"errcode":40003,"errmsg":"invalid openid hint: [WcOzcA02194104]"}
openid 没有传过去,查看请求,原来参数是要放body里,最后把请求参数放body里就可以了;
成功会响应:{"errcode":0,"errmsg":"ok"}
3.微信的接口测试地址:https://mp.weixin.qq.com/debug/
消息回复成功响应:{"errcode":0,"errmsg":"ok"}