| | |
| | | @Component |
| | | public class WeChatUtil { |
| | | |
| | | private String wxAppletsAppid="wx20301e30167d920e"; |
| | | private String wxAppletsAppid="wx0de58018e30d92ca"; |
| | | |
| | | private String wxAppletsAppSecret="4b8fe5cea20c4309fa996caa06ac9b4c"; |
| | | private String wxAppletsAppSecret="add17fe80420beb099d24d0cc17d0f6f"; |
| | | |
| | | @Autowired |
| | | private RestTemplate restTemplate; |
| | |
| | | * @return |
| | | */ |
| | | public Map<String, String> code2Session(String jscode){ |
| | | String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + "wx20301e30167d920e" + "&secret=" + "4b8fe5cea20c4309fa996caa06ac9b4c" |
| | | String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + "wx0de58018e30d92ca" + "&secret=" + "add17fe80420beb099d24d0cc17d0f6f" |
| | | + "&js_code=" + jscode + "&grant_type=authorization_code"; |
| | | String forObject = restTemplate.getForObject(url, String.class); |
| | | JSONObject jsonObject = JSON.parseObject(forObject); |
| | |
| | | String content = "jsapi_ticket=" + ticket + "&noncestr=" + noncestr + "×tamp=" + timestamp + "&url=" + url; |
| | | String signature = DigestUtils.sha1Hex(content); |
| | | Map<String,Object> map=new HashMap<>(); |
| | | map.put("appId", "wx20301e30167d920e"); |
| | | map.put("appId", "wx0de58018e30d92ca"); |
| | | map.put("timestamp", timestamp); |
| | | map.put("nonceStr", noncestr); |
| | | map.put("signature", signature); |