| | |
| | | @Component |
| | | public class WeChatUtil { |
| | | |
| | | @Value("${wx.appletsAppid}") |
| | | private String wxAppletsAppid; |
| | | private String wxAppletsAppid="wx20301e30167d920e"; |
| | | |
| | | @Value("${wx.appletsAppSecret}") |
| | | private String wxAppletsAppSecret; |
| | | private String wxAppletsAppSecret="4b8fe5cea20c4309fa996caa06ac9b4c"; |
| | | |
| | | @Autowired |
| | | private RestTemplate restTemplate; |
| | |
| | | * @return |
| | | */ |
| | | public Map<String, String> code2Session(String jscode){ |
| | | String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + wxAppletsAppid + "&secret=" + wxAppletsAppSecret |
| | | String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + "wx20301e30167d920e" + "&secret=" + "4b8fe5cea20c4309fa996caa06ac9b4c" |
| | | + "&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", wxAppletsAppid); |
| | | map.put("appId", "wx20301e30167d920e"); |
| | | map.put("timestamp", timestamp); |
| | | map.put("nonceStr", noncestr); |
| | | map.put("signature", signature); |