增加根据openid获取用户信息的重载方法,不指定语言,默认使用zh_CN

This commit is contained in:
Binary Wang 2016-10-27 11:56:46 +08:00
parent e89d009ae0
commit ed17c2aa39
2 changed files with 22 additions and 6 deletions

View File

@ -1,12 +1,12 @@
package me.chanjar.weixin.mp.api;
import java.util.List;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.bean.WxMpUserQuery;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import me.chanjar.weixin.mp.bean.result.WxMpUserList;
import java.util.List;
/**
* 用户管理相关操作接口
*
@ -25,10 +25,22 @@ public interface WxMpUserService {
*/
void userUpdateRemark(String openid, String remark) throws WxErrorException;
/**
* <pre>
* 获取用户基本信息语言为默认的zh_CN 简体
* 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140839&token=&lang=zh_CN
* http请求方式: GET https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN
* </pre>
*
* @param openid 用户openid
*/
WxMpUser userInfo(String openid) throws WxErrorException;
/**
* <pre>
* 获取用户基本信息
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=获取用户基本信息
* 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140839&token=&lang=zh_CN
* http请求方式: GET https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN
* </pre>
*
* @param openid 用户openid

View File

@ -1,9 +1,6 @@
package me.chanjar.weixin.mp.api.impl;
import java.util.List;
import com.google.gson.JsonObject;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.WxMpUserService;
@ -11,6 +8,8 @@ import me.chanjar.weixin.mp.bean.WxMpUserQuery;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import me.chanjar.weixin.mp.bean.result.WxMpUserList;
import java.util.List;
/**
* Created by Binary Wang on 2016/7/21.
*/
@ -31,6 +30,11 @@ public class WxMpUserServiceImpl implements WxMpUserService {
this.wxMpService.post(url, json.toString());
}
@Override
public WxMpUser userInfo(String openid) throws WxErrorException {
return this.userInfo(openid, null);
}
@Override
public WxMpUser userInfo(String openid, String lang) throws WxErrorException {
String url = API_URL_PREFIX + "/info";