|
|
@@ -9,6 +9,8 @@ import com.usoftchina.smartschool.school.wxschool.basic.service.WxUserService;
|
|
|
import com.usoftchina.smartschool.school.wxschool.utils.ObjectUtils;
|
|
|
import com.usoftchina.smartschool.school.wxschool.utils.ResultBean;
|
|
|
import org.apache.ibatis.annotations.Param;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.util.Assert;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
@@ -35,6 +37,8 @@ import static com.usoftchina.smartschool.school.wxschool.utils.ResultBean.ErrorC
|
|
|
@RestController
|
|
|
@RequestMapping("/wxSchool/user")
|
|
|
public class WxUserController {
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(WxUserController.class);
|
|
|
+
|
|
|
@Autowired
|
|
|
private WxUserService userService;
|
|
|
|
|
|
@@ -124,17 +128,23 @@ public class WxUserController {
|
|
|
params.put("grant_type", "authorization_code");
|
|
|
HttpRequest response= HttpRequest.get("https://api.weixin.qq.com/sns/oauth2/access_token", params, true);
|
|
|
String result=response.body();
|
|
|
-
|
|
|
+ log.info("result======"+result);
|
|
|
String openid= JSON.parseObject(result).getString("openid");
|
|
|
+ log.info("openid======="+openid);
|
|
|
String token= JSON.parseObject(result).getString("access_token");
|
|
|
+ log.info("token====="+token);
|
|
|
HashMap<String, Object> param=new HashMap<>();
|
|
|
param.put("openid",openid);
|
|
|
param.put("access_token",token);
|
|
|
param.put("lang","zh_CN");
|
|
|
- HttpRequest res= HttpRequest.get("https://api.weixin.qq.com/cgi-bin/user/info", param, true);
|
|
|
+ HttpRequest res= HttpRequest.get("https://api.weixin.qq.com/sns/userinfo", param, true);
|
|
|
+ //HttpRequest res= HttpRequest.get("https://api.weixin.qq.com/cgi-bin/user/info", param, true);
|
|
|
String body = res.body();
|
|
|
- System.err.println(body);
|
|
|
- return new ModelAndView("redirect:https://school-wechat.ubtob.com/bindMenu/open/"+openid);
|
|
|
+ log.info("res======"+res);
|
|
|
+ log.info("body======"+body);
|
|
|
+ String headimgurl = JSON.parseObject(result).getString("headimgurl");
|
|
|
+ log.info("headimgurl======"+headimgurl);
|
|
|
+ return new ModelAndView("redirect:https://school-wechat.ubtob.com/bindMenu/open/"+openid+"/headimgurl/"+headimgurl);
|
|
|
}
|
|
|
|
|
|
/**
|