Visitar URL original
/cgi-bin/auth/getuserinfo 返回的字段是userid 小写 但是代码里大写导致获取失败 · Issue #33 · binarywang/weixin-java-cp-demo · GitHub
Skip to content

/cgi-bin/auth/getuserinfo 返回的字段是userid 小写 但是代码里大写导致获取失败 #33

Closed

Description

@dan334540507

public WxCpOauth2UserInfo getAuthUserInfo(String code) throws WxErrorException {
String responseText = this.mainService.get(String.format(this.mainService.getWxCpConfigStorage().getApiUrl("/cgi-bin/auth/getuserinfo?code=%s"), code), (String)null);
JsonObject jo = GsonParser.parse(responseText);
return WxCpOauth2UserInfo.builder().userId(GsonHelper.getString(jo, "UserId")).openId(GsonHelper.getString(jo, "OpenId")).userTicket(GsonHelper.getString(jo, "user_ticket")).externalUserId(GsonHelper.getString(jo, "external_userid")).build();
}
这边GsonHelper.getString(jo, "UserId") 应该是 GsonHelper.getString(jo, "userid")
版本:

com.github.binarywang
weixin-java-cp
4.6.0

Activity

  1. binarywang commented on Aug 21, 2024

    @binarywang
    Owner

    欢迎直接在WxJava项目里提交PR修复代码,谢谢!

  2. binarywang commented on Sep 8, 2024

    @binarywang
    Owner

    你用的的版本有些老,最新版已经更新了

  3. binarywang commented on Sep 8, 2024

    @binarywang
    Owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions