diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpUserServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpUserServiceImpl.java index 995eb58a..6af109e7 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpUserServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpUserServiceImpl.java @@ -56,7 +56,7 @@ public class WxMpUserServiceImpl implements WxMpUserService { @Override public List userInfoList(WxMpUserQuery userQuery) throws WxErrorException { String url = API_URL_PREFIX + "/info/batchget"; - String responseContent = this.wxMpService.execute(new SimpleGetRequestExecutor(), url, userQuery.toJsonString()); + String responseContent = this.wxMpService.execute(new SimplePostRequestExecutor(), url, userQuery.toJsonString()); return WxMpUser.fromJsonList(responseContent); } diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserServiceImplTest.java index 4167a852..4133d3a3 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserServiceImplTest.java @@ -1,5 +1,9 @@ + package me.chanjar.weixin.mp.api.impl; +import java.util.ArrayList; +import java.util.List; + import org.testng.Assert; import org.testng.annotations.Guice; import org.testng.annotations.Test; @@ -9,6 +13,7 @@ import com.google.inject.Inject; import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.mp.api.ApiTestModule; import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage; +import me.chanjar.weixin.mp.bean.WxMpUserQuery; import me.chanjar.weixin.mp.bean.result.WxMpUser; import me.chanjar.weixin.mp.bean.result.WxMpUserList; @@ -36,6 +41,24 @@ public class WxMpUserServiceImplTest { Assert.assertNotNull(user); System.out.println(user); } + + public void testUserInfoList() throws WxErrorException { + WxXmlMpInMemoryConfigStorage configProvider = (WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage(); + List openIdList = new ArrayList<>(); + openIdList.add(configProvider.getOpenid()); + List userList = this.wxService.getUserService().userInfoList(openIdList); + Assert.assertEquals(userList.size(), 1); + System.out.println(userList); + } + + public void testUserInfoListByWxMpUserQuery() throws WxErrorException { + WxXmlMpInMemoryConfigStorage configProvider = (WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage(); + WxMpUserQuery query = new WxMpUserQuery(); + query.add(configProvider.getOpenid(), "zh_CN"); + List userList = this.wxService.getUserService().userInfoList(query); + Assert.assertEquals(userList.size(), 1); + System.out.println(userList); + } public void testUserList() throws WxErrorException { WxMpUserList wxMpUserList = this.wxService.getUserService().userList(null); @@ -45,5 +68,6 @@ public class WxMpUserServiceImplTest { Assert.assertFalse(wxMpUserList.getOpenIds().size() == -1); System.out.println(wxMpUserList); } + }