
net.sf.weixinmp.saas.dialog.user.GetUserInGroupRequest Maven / Gradle / Ivy
The newest version!
package net.sf.weixinmp.saas.dialog.user;
import java.nio.charset.UnsupportedCharsetException;
import org.apache.http.HttpEntity;
import org.apache.http.entity.StringEntity;
import net.sf.weixinmp.model.GenericObject;
import net.sf.weixinmp.saas.WeixinmpRequest;
/**
* http://mp.weixin.qq.com/wiki/13/be5272dc4930300ba561d927aead2569.html
* 查询用户所在分组
* @author Alex
*
*/
public class GetUserInGroupRequest extends WeixinmpRequest {
public int execute(String accessToken, String openId) {
String xml = "{\"openid\":\"" + openId + "\"}";
HttpEntity entity;
try {
entity = new StringEntity(xml, "UTF-8");
String s = this.requestContentString("/groups/getid?access_token=" + accessToken, entity);
GenericObject map = toNativeMap(s);
return map.getInt("groupid", -1);
} catch (UnsupportedCharsetException e) {
e.printStackTrace();
}
return -1;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy