1 小程序文档地址
2 具体代码
/**
* 微信根据报错信息rid值,查询访问接口信息
*/
public static void main(String[] args) {
//获取access_token
String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=?&secret=?";
String access_token = "";
String code = "";
try (Response response = OkHttpUtil.get(url)) {
log.info("接口调用凭证:response=" + response.toString());
if (response.isSuccessful()) {
JSONObject resData = com.alibaba.fastjson.JSON.parseObject(response.body().string());
Integer errcode = resData.getInteger("errcode");
if (errcode == null || errcode == 0) {
access_token = resData.getString("access_token");
String urlddd = "https://api.weixin.qq.com/cgi-bin/openapi/rid/get?access_token=" + access_token;
JSONObject jsonObject = new JSONObject();
jsonObject.put("rid","64ca2719-435a5d83-380f5a1e");
Response msgResponse = OkHttpUtil.postJson(urlddd, null, jsonObject.toJSONString());
JSONObject msgJson = JSONObject.parseObject(msgResponse.body().string());
log.info("返回结果:" + msgJson);
}
}
} catch (Exception e) {
}
}