示例#1
0
        private void webwxgetcontact()
        {
            ShowMsg("webwxgetcontact");
            if (true)
            {
                var url = "https://wx[number].qq.com/cgi-bin/mmwebwx-bin/webwxgetcontact?pass_ticket={pass_ticket}&r={time}&skey={SKEY}";

                HttpWebRequest h = (HttpWebRequest)HttpWebRequest.Create(ReplaceKey(url));
                h.AllowAutoRedirect = false;
                h.CookieContainer   = cookieContainer;
                //提取全部的cookie

                h.Accept = "application/json, text/plain, */*";
                HttpWebResponse  r       = (HttpWebResponse)h.GetResponse();
                CookieCollection cookies = r.Cookies;

                using (System.IO.StreamReader read = new System.IO.StreamReader(r.GetResponseStream()))
                {
                    string value = read.ReadToEnd();
                    USER_LIST = JavaScriptConvert.DeserializeObject(value) as JavaScriptObject;

                    //显示到list中
                    var arr = USER_LIST["MemberList"] as JavaScriptArray;
                    DataContractJsonSerializer jss = new DataContractJsonSerializer(typeof(FriendDataResponse));

                    data       = value.ConvertJson <FriendDataResponse>();
                    friendList = data;


                    foreach (JavaScriptObject o in arr)
                    {
                        USER_DI[o["UserName"] + ""] = o["NickName"] + "";
                        //NickName
                    }
                }
                r.Close();
                bool                 onlyFriend = ckOnlyFriend.Checked;
                List <Friend>        friends    = new List <Friend>();
                IEnumerable <Friend> ef;
                if (onlyFriend)
                {
                    ef = data.MemberList.Where(m =>
                    {
                        m.AliasDesc = m.UserName.Replace("@", "").Convert16ToString();
                        return(m.SelfDefineType == FriendDataCategory.Friend);
                    });
                }
                else
                {
                    ef = data.MemberList;
                }
                friends = ef.OrderBy(s => s.OrderByName).ToList();
                // data.MemberList.Sort(data.MemberList)
                ListBindDataSource(friends);
            }
        }
示例#2
0
        private void webwxgetcontact()
        {
            ShowMsg("webwxgetcontact");
            FriendDataResponse data = new FriendDataResponse();

            if (true)
            {
                var url = "https://wx[number].qq.com/cgi-bin/mmwebwx-bin/webwxgetcontact?pass_ticket={pass_ticket}&r={time}&skey={SKEY}";

                HttpWebRequest h = (HttpWebRequest)HttpWebRequest.Create(ReplaceKey(url));
                h.AllowAutoRedirect = false;
                h.CookieContainer   = cookieContainer;
                h.Accept            = "application/json, text/plain, */*";
                HttpWebResponse r = (HttpWebResponse)h.GetResponse();

                using (System.IO.StreamReader read = new System.IO.StreamReader(r.GetResponseStream()))
                {
                    string value = read.ReadToEnd();
                    USER_LIST = JavaScriptConvert.DeserializeObject(value) as JavaScriptObject;

                    //显示到list中
                    var arr = USER_LIST["MemberList"] as JavaScriptArray;
                    DataContractJsonSerializer jss = new DataContractJsonSerializer(typeof(FriendDataResponse));

                    data = value.ConvertJson <FriendDataResponse>();

                    lstBoxUser.Items.Clear();

                    foreach (JavaScriptObject o in arr)
                    {
                        USER_DI[o["UserName"] + ""] = o["NickName"] + "";
                        //NickName
                        lstBoxUser.Items.Add(o["NickName"] + ">" + o["UserName"]);
                    }
                }
                r.Close();
                ListBindDataSource(data.MemberList);
            }
        }