日期:2014-05-16 浏览次数:21020 次
/// <summary>
/// 获取用户ID
/// </summary>
/// <param name="count">需要获取的用户数</param>
/// <param name="pageidx">当前页(默认为0)</param>
/// <param name="groupid">分组ID(默认为0,表示未分组的用户)</param>
/// <returns></returns>
public static ArrayList SubscribeMP(int? pagesize, int? pageidx, int? groupid)
{
try
{
/*获取用户信息的url,这里有几个参数给大家讲一下,1.token此参数为上面的token 2.pagesize此参数为每一页显示的记录条数3.pageid为当前的页数,4.groupid为微信公众平台的用户分组的组id*/
CookieContainer cookie = null;
string token = null;
cookie = WeiXinLoginCookie.LoginCookie;//取得cookie
token = WeiXinLoginCookie.Token;//取得token
string Url = " https://mp.weixin.qq.com/cgi-bin/contactmanage?t=user/index&pagesize=" + pagesize + "&pageidx=" + pageidx + "&type=0&token=" + token + "&lang=zh_CN";
HttpWebRequest webRequest2 = (HttpWebRequest)WebRequest.Create(Url);
webRequest2.CookieContainer = cookie;
webRequest2.ContentType = "text/html; charset=UTF-8";
webRequest2.Method = "GET";
webRequest2.ContentType = "application/x-www-form-urlencoded";
webRequest2.UserAgent = "Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1";
//webRequest2.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.62 Safari/537.36";
HttpWebResponse response2 = (HttpWebResponse)