11package me .chanjar .weixin .cp .api .impl ;
22
3+ import com .google .gson .GsonBuilder ;
34import com .google .gson .JsonElement ;
45import com .google .gson .JsonObject ;
56import com .google .gson .JsonParser ;
89import me .chanjar .weixin .common .util .json .GsonHelper ;
910import me .chanjar .weixin .cp .api .WxCpOAuth2Service ;
1011import me .chanjar .weixin .cp .api .WxCpService ;
12+ import me .chanjar .weixin .cp .bean .WxCpUserDetail ;
1113
1214/**
1315 * <pre>
@@ -52,9 +54,8 @@ public String[] getUserInfo(String code) throws WxErrorException {
5254
5355 @ Override
5456 public String [] getUserInfo (Integer agentId , String code ) throws WxErrorException {
55- String url = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?"
56- + "code=" + code
57- + "&agentid=" + agentId ;
57+ String url = String .format ("https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?code=%s&agentid=%d" ,
58+ code , agentId );
5859 String responseText = this .mainService .get (url , null );
5960 JsonElement je = new JsonParser ().parse (responseText );
6061 JsonObject jo = je .getAsJsonObject ();
@@ -63,4 +64,12 @@ public String[] getUserInfo(Integer agentId, String code) throws WxErrorExceptio
6364 GsonHelper .getString (jo , "OpenId" )};
6465 }
6566
67+ @ Override
68+ public WxCpUserDetail getUserDetail (String userTicket ) throws WxErrorException {
69+ String url = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserdetail" ;
70+ JsonObject param = new JsonObject ();
71+ param .addProperty ("user_ticket" , userTicket );
72+ String responseText = this .mainService .post (url , param .toString ());
73+ return new GsonBuilder ().create ().fromJson (responseText , WxCpUserDetail .class );
74+ }
6675}
0 commit comments