com.foxinmy.weixin4j.mp.api
Class UserApi

java.lang.Object
  extended by com.foxinmy.weixin4j.api.BaseApi
      extended by com.foxinmy.weixin4j.mp.api.MpApi
          extended by com.foxinmy.weixin4j.mp.api.UserApi

public class UserApi
extends MpApi

用户相关API

Since:
JDK 1.6
Author:
jinyu(foxinmy@gmail.com)
See Also:
User

Constructor Summary
UserApi(TokenManager tokenManager)
           
 
Method Summary
 List<User> getAllFollowing()
          获取公众号全部的关注者列表 请慎重使用
 List<String> getAllFollowingOpenIds()
          获取公众号全部的关注者列表 请慎重使用
 Following getFollowing(String nextOpenId)
          获取公众号一定数量(10000)的关注者列表 请慎重使用
 Following getFollowingOpenIds(String nextOpenId)
          获取公众号一定数量(10000)的关注者列表
 User getUser(String openId)
          获取用户信息
 User getUser(String openId, Lang lang)
          获取用户信息
 List<User> getUsers(Lang lang, String... openIds)
          批量获取用户信息
 List<User> getUsers(String... openIds)
          批量获取用户信息
 ApiResult remarkUserName(String openId, String remark)
          设置用户备注名
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserApi

public UserApi(TokenManager tokenManager)
Method Detail

getUser

public User getUser(String openId)
             throws WeixinException
获取用户信息

Parameters:
openId - 用户对应的ID
Returns:
用户对象
Throws:
WeixinException
See Also:
#getUser(String,Lang)}

getUser

public User getUser(String openId,
                    Lang lang)
             throws WeixinException
获取用户信息

在关注者与公众号产生消息交互后,公众号可获得关注者的OpenID(加密后的微信号,每个用户对每个公众号的OpenID是唯一的,对于不同公众号, 同一用户的openid不同),公众号可通过本接口来根据OpenID获取用户基本信息,包括昵称、头像、性别、所在城市、语言和关注时间

Parameters:
openId - 用户对应的ID
lang - 国家地区语言版本
Returns:
用户对象
Throws:
WeixinException
See Also:
获取用户信息, Lang, User

getUsers

public List<User> getUsers(String... openIds)
                    throws WeixinException
批量获取用户信息

Parameters:
openIds - 用户ID
Returns:
用户列表
Throws:
WeixinException
See Also:
获取用户信息, User, #getUsers(Lang,String[])}

getUsers

public List<User> getUsers(Lang lang,
                           String... openIds)
                    throws WeixinException
批量获取用户信息

Parameters:
lang - 国家地区语言版本
openIds - 用户ID 最多100个
Returns:
用户列表
Throws:
WeixinException
See Also:
获取用户信息, Lang, User

getFollowing

public Following getFollowing(String nextOpenId)
                       throws WeixinException
获取公众号一定数量(10000)的关注者列表 请慎重使用

Parameters:
nextOpenId - 下一次拉取数据的openid 不填写则默认从头开始拉取
Returns:
关注者信息 包含用户的详细信息
Throws:
WeixinException
See Also:
获取关注者列表, 批量获取用户信息, Following, User

getFollowingOpenIds

public Following getFollowingOpenIds(String nextOpenId)
                              throws WeixinException
获取公众号一定数量(10000)的关注者列表

Parameters:
nextOpenId - 下一次拉取数据的openid 不填写则默认从头开始拉取
Returns:
关注者信息 不包含用户的详细信息
Throws:
WeixinException
See Also:
获取关注者列表, Following

getAllFollowing

public List<User> getAllFollowing()
                           throws WeixinException
获取公众号全部的关注者列表 请慎重使用

当公众号关注者数量超过10000时,可通过填写next_openid的值,从而多次拉取列表的方式来满足需求, 将上一次调用得到的返回中的next_openid值,作为下一次调用中的next_openid值

Returns:
用户对象集合
Throws:
WeixinException
See Also:
获取关注者列表, 批量获取用户信息, User, Following, getFollowing(String)

getAllFollowingOpenIds

public List<String> getAllFollowingOpenIds()
                                    throws WeixinException
获取公众号全部的关注者列表 请慎重使用

当公众号关注者数量超过10000时,可通过填写next_openid的值,从而多次拉取列表的方式来满足需求, 将上一次调用得到的返回中的next_openid值,作为下一次调用中的next_openid值

Returns:
用户openid集合
Throws:
WeixinException
See Also:
获取关注者列表, getFollowingOpenIds(String)

remarkUserName

public ApiResult remarkUserName(String openId,
                                String remark)
                         throws WeixinException
设置用户备注名

Parameters:
openId - 用户ID
remark - 备注名
Throws:
WeixinException
See Also:
设置用户备注名


Copyright © 2014–2017. All rights reserved.