1
0
mirror of synced 2025-12-27 13:37:59 +08:00

#1053 企业微信根据code获取成员信息接口返回结果优化

This commit is contained in:
Binary Wang
2019-05-26 17:03:50 +08:00
parent f956d9640a
commit 1923047292
5 changed files with 85 additions and 36 deletions

View File

@@ -4,10 +4,13 @@ import com.google.inject.Inject;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.ApiTestModule;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.WxCpOauth2UserInfo;
import me.chanjar.weixin.cp.bean.WxCpUserDetail;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* <pre>
* Created by BinaryWang on 2018/4/22.
@@ -28,6 +31,13 @@ public class WxCpOAuth2ServiceImplTest {
@Test
public void testGetUserInfo() throws WxErrorException {
this.wxService.getOauth2Service().getUserInfo("abc");
final WxCpOauth2UserInfo result = this.wxService.getOauth2Service().getUserInfo("abc");
assertThat(result).isNotNull();
System.out.println(result);
}
@Test
public void testBuildAuthorizationUrl() {
}
}

View File

@@ -2,6 +2,7 @@ package me.chanjar.weixin.cp.demo;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.WxCpOauth2UserInfo;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@@ -30,9 +31,9 @@ public class WxCpOAuth2Servlet extends HttpServlet {
response.getWriter().println("<h1>code</h1>");
response.getWriter().println(code);
String[] res = this.wxCpService.getOauth2Service().getUserInfo(code);
WxCpOauth2UserInfo res = this.wxCpService.getOauth2Service().getUserInfo(code);
response.getWriter().println("<h1>result</h1>");
response.getWriter().println(Arrays.toString(res));
response.getWriter().println(res);
} catch (WxErrorException e) {
e.printStackTrace();
}