Skip to content

Commit 013835f

Browse files
committed
企业微信根据code获取成员信息接口返回值增加user_ticket和expires
1 parent c237bb8 commit 013835f

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOAuth2Service.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,17 @@ public interface WxCpOAuth2Service {
5151

5252
/**
5353
* <pre>
54-
* 用oauth2获取用户信息
54+
* 根据code获取成员信息
5555
* http://qydev.weixin.qq.com/wiki/index.php?title=根据code获取成员信息
56+
* https://work.weixin.qq.com/api/doc#10028/根据code获取成员信息
5657
* 因为企业号oauth2.0必须在应用设置里设置通过ICP备案的可信域名,所以无法测试,因此这个方法很可能是坏的。
5758
*
5859
* 注意: 这个方法不使用WxCpConfigStorage里的agentId,需要开发人员自己给出
5960
* </pre>
6061
*
6162
* @param agentId 企业号应用的id
62-
* @param code 微信oauth授权返回的代码
63-
* @return [userid, deviceid]
63+
* @param code 通过成员授权获取到的code,最大为512字节。每次成员授权带上的code将不一样,code只能使用一次,5分钟未被使用自动过期。
64+
* @return [UserId, DeviceId, OpenId, user_ticket, expires_in]
6465
* @see #getUserInfo(String)
6566
*/
6667
String[] getUserInfo(Integer agentId, String code) throws WxErrorException;

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOAuth2ServiceImpl.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*
1717
* Created by Binary Wang on 2017-6-25.
1818
* @author <a href="https://github.com/binarywang">Binary Wang</a>
19+
*
20+
* @author Binary Wang
1921
* </pre>
2022
*/
2123
public class WxCpOAuth2ServiceImpl implements WxCpOAuth2Service {
@@ -61,7 +63,10 @@ public String[] getUserInfo(Integer agentId, String code) throws WxErrorExceptio
6163
JsonObject jo = je.getAsJsonObject();
6264
return new String[]{GsonHelper.getString(jo, "UserId"),
6365
GsonHelper.getString(jo, "DeviceId"),
64-
GsonHelper.getString(jo, "OpenId")};
66+
GsonHelper.getString(jo, "OpenId"),
67+
GsonHelper.getString(jo, "user_ticket"),
68+
GsonHelper.getString(jo, "expires_in")
69+
};
6570
}
6671

6772
@Override

0 commit comments

Comments
 (0)