@@ -94,8 +94,8 @@ public interface WxMpUserTagService { | |||||
* 详情请见:<a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140837&token=&lang=zh_CN">用户标签管理</a> | * 详情请见:<a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140837&token=&lang=zh_CN">用户标签管理</a> | ||||
* 接口url格式: https://api.weixin.qq.com/cgi-bin/tags/getidlist?access_token=ACCESS_TOKEN | * 接口url格式: https://api.weixin.qq.com/cgi-bin/tags/getidlist?access_token=ACCESS_TOKEN | ||||
* </pre> | * </pre> | ||||
* | |||||
* @return 标签Id的列表 | |||||
*/ | */ | ||||
List<Integer> userTagList(String openid) throws WxErrorException; | |||||
List<Long> userTagList(String openid) throws WxErrorException; | |||||
} | } |
@@ -1,9 +1,14 @@ | |||||
package me.chanjar.weixin.mp.api.impl; | package me.chanjar.weixin.mp.api.impl; | ||||
import java.util.List; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import com.google.gson.JsonArray; | import com.google.gson.JsonArray; | ||||
import com.google.gson.JsonObject; | import com.google.gson.JsonObject; | ||||
import com.google.gson.JsonParser; | import com.google.gson.JsonParser; | ||||
import com.google.gson.reflect.TypeToken; | import com.google.gson.reflect.TypeToken; | ||||
import me.chanjar.weixin.common.bean.result.WxError; | import me.chanjar.weixin.common.bean.result.WxError; | ||||
import me.chanjar.weixin.common.exception.WxErrorException; | import me.chanjar.weixin.common.exception.WxErrorException; | ||||
import me.chanjar.weixin.mp.api.WxMpService; | import me.chanjar.weixin.mp.api.WxMpService; | ||||
@@ -11,9 +16,6 @@ import me.chanjar.weixin.mp.api.WxMpUserTagService; | |||||
import me.chanjar.weixin.mp.bean.tag.WxTagListUser; | import me.chanjar.weixin.mp.bean.tag.WxTagListUser; | ||||
import me.chanjar.weixin.mp.bean.tag.WxUserTag; | import me.chanjar.weixin.mp.bean.tag.WxUserTag; | ||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | ||||
import org.apache.commons.lang3.StringUtils; | |||||
import java.util.List; | |||||
/** | /** | ||||
* | * | ||||
@@ -144,7 +146,7 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService { | |||||
} | } | ||||
@Override | @Override | ||||
public List<Integer> userTagList(String openid) throws WxErrorException { | |||||
public List<Long> userTagList(String openid) throws WxErrorException { | |||||
String url = API_URL_PREFIX + "/getidlist"; | String url = API_URL_PREFIX + "/getidlist"; | ||||
JsonObject json = new JsonObject(); | JsonObject json = new JsonObject(); | ||||
@@ -154,7 +156,7 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService { | |||||
return WxMpGsonBuilder.create().fromJson( | return WxMpGsonBuilder.create().fromJson( | ||||
new JsonParser().parse(responseContent).getAsJsonObject().get("tagid_list"), | new JsonParser().parse(responseContent).getAsJsonObject().get("tagid_list"), | ||||
new TypeToken<List<Integer>>() { | |||||
new TypeToken<List<Long>>() { | |||||
}.getType()); | }.getType()); | ||||
} | } | ||||
} | } |
@@ -1,15 +1,17 @@ | |||||
package me.chanjar.weixin.mp.api.impl; | package me.chanjar.weixin.mp.api.impl; | ||||
import java.util.List; | |||||
import org.testng.Assert; | |||||
import org.testng.annotations.Guice; | |||||
import org.testng.annotations.Test; | |||||
import com.google.inject.Inject; | import com.google.inject.Inject; | ||||
import me.chanjar.weixin.mp.api.ApiTestModule; | import me.chanjar.weixin.mp.api.ApiTestModule; | ||||
import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage; | import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage; | ||||
import me.chanjar.weixin.mp.bean.tag.WxTagListUser; | import me.chanjar.weixin.mp.bean.tag.WxTagListUser; | ||||
import me.chanjar.weixin.mp.bean.tag.WxUserTag; | import me.chanjar.weixin.mp.bean.tag.WxUserTag; | ||||
import org.testng.Assert; | |||||
import org.testng.annotations.Guice; | |||||
import org.testng.annotations.Test; | |||||
import java.util.List; | |||||
/** | /** | ||||
* | * | ||||
@@ -80,7 +82,7 @@ public class WxMpUserTagServiceImplTest { | |||||
@Test | @Test | ||||
public void testUserTagList() throws Exception { | public void testUserTagList() throws Exception { | ||||
List<Integer> res = this.wxService.getUserTagService().userTagList( | |||||
List<Long> res = this.wxService.getUserTagService().userTagList( | |||||
((WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage()).getOpenid()); | ((WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage()).getOpenid()); | ||||
System.out.println(res); | System.out.println(res); | ||||
Assert.assertNotNull(res); | Assert.assertNotNull(res); | ||||