| @@ -51,16 +51,17 @@ public interface WxCpOAuth2Service { | |||||
| /** | /** | ||||
| * <pre> | * <pre> | ||||
| * 用oauth2获取用户信息 | |||||
| * 根据code获取成员信息 | |||||
| * http://qydev.weixin.qq.com/wiki/index.php?title=根据code获取成员信息 | * http://qydev.weixin.qq.com/wiki/index.php?title=根据code获取成员信息 | ||||
| * https://work.weixin.qq.com/api/doc#10028/根据code获取成员信息 | |||||
| * 因为企业号oauth2.0必须在应用设置里设置通过ICP备案的可信域名,所以无法测试,因此这个方法很可能是坏的。 | * 因为企业号oauth2.0必须在应用设置里设置通过ICP备案的可信域名,所以无法测试,因此这个方法很可能是坏的。 | ||||
| * | * | ||||
| * 注意: 这个方法不使用WxCpConfigStorage里的agentId,需要开发人员自己给出 | * 注意: 这个方法不使用WxCpConfigStorage里的agentId,需要开发人员自己给出 | ||||
| * </pre> | * </pre> | ||||
| * | * | ||||
| * @param agentId 企业号应用的id | * @param agentId 企业号应用的id | ||||
| * @param code 微信oauth授权返回的代码 | |||||
| * @return [userid, deviceid] | |||||
| * @param code 通过成员授权获取到的code,最大为512字节。每次成员授权带上的code将不一样,code只能使用一次,5分钟未被使用自动过期。 | |||||
| * @return [UserId, DeviceId, OpenId, user_ticket, expires_in] | |||||
| * @see #getUserInfo(String) | * @see #getUserInfo(String) | ||||
| */ | */ | ||||
| String[] getUserInfo(Integer agentId, String code) throws WxErrorException; | String[] getUserInfo(Integer agentId, String code) throws WxErrorException; | ||||
| @@ -16,6 +16,8 @@ import me.chanjar.weixin.cp.bean.WxCpUserDetail; | |||||
| * | * | ||||
| * Created by Binary Wang on 2017-6-25. | * Created by Binary Wang on 2017-6-25. | ||||
| * @author <a href="https://github.com/binarywang">Binary Wang</a> | * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||
| * | |||||
| * @author Binary Wang | |||||
| * </pre> | * </pre> | ||||
| */ | */ | ||||
| public class WxCpOAuth2ServiceImpl implements WxCpOAuth2Service { | public class WxCpOAuth2ServiceImpl implements WxCpOAuth2Service { | ||||
| @@ -61,7 +63,10 @@ public class WxCpOAuth2ServiceImpl implements WxCpOAuth2Service { | |||||
| JsonObject jo = je.getAsJsonObject(); | JsonObject jo = je.getAsJsonObject(); | ||||
| return new String[]{GsonHelper.getString(jo, "UserId"), | return new String[]{GsonHelper.getString(jo, "UserId"), | ||||
| GsonHelper.getString(jo, "DeviceId"), | GsonHelper.getString(jo, "DeviceId"), | ||||
| GsonHelper.getString(jo, "OpenId")}; | |||||
| GsonHelper.getString(jo, "OpenId"), | |||||
| GsonHelper.getString(jo, "user_ticket"), | |||||
| GsonHelper.getString(jo, "expires_in") | |||||
| }; | |||||
| } | } | ||||
| @Override | @Override | ||||