Java Code Examples for me.chanjar.weixin.mp.bean.result.WxMpUser#fromJson()

The following examples show how to use me.chanjar.weixin.mp.bean.result.WxMpUser#fromJson() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseWxMpServiceImpl.java    From weixin-java-tools with Apache License 2.0 6 votes vote down vote up
@Override
public WxMpUser oauth2getUserInfo(WxMpOAuth2AccessToken token, String lang) throws WxErrorException {
  if (lang == null) {
    lang = "zh_CN";
  }

  String url = String.format(WxMpService.OAUTH2_USERINFO_URL, token.getAccessToken(), token.getOpenId(), lang);

  try {
    RequestExecutor<String, String> executor = SimpleGetRequestExecutor.create(this);
    String responseText = executor.execute(url, null);
    return WxMpUser.fromJson(responseText);
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
Example 2
Source File: WxMpUserServiceImpl.java    From weixin-java-tools with Apache License 2.0 5 votes vote down vote up
@Override
public WxMpUser userInfo(String openid, String lang) throws WxErrorException {
  String url = API_URL_PREFIX + "/info";
  lang = lang == null ? "zh_CN" : lang;
  String responseContent = this.wxMpService.get(url,
    "openid=" + openid + "&lang=" + lang);
  return WxMpUser.fromJson(responseContent);
}
 
Example 3
Source File: WxMpServiceImpl.java    From weixin-java-tools with Apache License 2.0 4 votes vote down vote up
public WxMpUser userInfo(String openid, String lang) throws WxErrorException {
  String url = "https://api.weixin.qq.com/cgi-bin/user/info";
  lang = lang == null ? "zh_CN" : lang;
  String responseContent = execute(new SimpleGetRequestExecutor(), url, "openid=" + openid + "&lang=" + lang);
  return WxMpUser.fromJson(responseContent);
}