| | |
| | | |
| | | |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.HttpMethod; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.client.RestClientException; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.moral.api.service.UserLogService; |
| | | |
| | | public class WechatUtils { |
| | | |
| | | public static final String APPID = "yyyy"; |
| | | public static final String SECRET = "yyyy"; |
| | | |
| | | public static final String APPID = "wx41f4c3c007545088"; |
| | | public static final String SECRET = "9e1a328ad525dd169252a1cc5067a6f3"; |
| | | |
| | | public static JSONObject getSessionKeyOrOpenId(String code) { |
| | | |
| | | String requestUrl = "https://api.weixin.qq.com/sns/jscode2session"; |
| | | Map<String, String> requestUrlParam = new HashMap<>(); |
| | | // https://mp.weixin.qq.com/wxopen/devprofile?action=get_profile&token=164113089&lang=zh_CN |
| | |
| | | requestUrlParam.put("grant_type", "authorization_code"); |
| | | //发送post请求读取调用微信接口获取openid用户唯一标识 |
| | | JSONObject jsonObject = JSON.parseObject(HttpClientUtil.doPost(requestUrl, requestUrlParam)); |
| | | |
| | | return jsonObject; |
| | | } |
| | | } |