コード例 #1
0
 public FriendList Get_Friend_List()
 {
     try
     {
         using (HttpWebClient httpWebClient = new HttpWebClient())
         {
             string address = "https://qun.qq.com/cgi-bin/qun_mgr/get_friend_list";
             string s       = $"bkn={Bkn}";
             httpWebClient.Headers["Accept"]           = "application/json, text/javascript, */*; q=0.01";
             httpWebClient.Headers["Referer"]          = "http://qun.qq.com/member.html";
             httpWebClient.Headers["X-Requested-With"] = "XMLHttpRequest";
             httpWebClient.Headers["User-Agent"]       = UA;
             httpWebClient.Headers.Add("Cache-Control: no-cache");
             httpWebClient.Cookies = QunCookies;
             string text = Encoding.UTF8.GetString(httpWebClient.UploadData(address, "POST", Encoding.UTF8.GetBytes(s)));
             Regex  r    = new Regex("\"[0-9]+\":");
             if (r.IsMatch(text))
             {
                 foreach (var match in r.Matches(text))
                 {
                     var str = ((Capture)match).Value;
                     text = text.Replace(str, "");
                 }
                 text = text.Replace("\"result\":{{", "\"result\":[{").Replace("\"}}}", "\"}]}");
             }
             MessageLog("获取好友列表成功:" + text);
             return(JsonConvert.DeserializeObject <FriendList>(text));
         }
     }
     catch (Exception ex)
     {
         MessageLog("获取好友列表失败:" + ex.Message);
     }
     return(null);
 }
コード例 #2
0
ファイル: TestDataFetcher.cs プロジェクト: jameschen00/sdnuoj
        public byte[] Fetch(string problemID)
        {
            string body = CreateRequestBody(problemID);

            byte[] result = _httpClient.UploadData(_config.TestDataFetchUrl, body, 3);
            result = ChangeVersionFileName(result);

            return(result);
        }
コード例 #3
0
ファイル: QQUser.cs プロジェクト: kilingzhang/PCQQ-Protocol
        public GroupList Get_Group_List()
        {
            try
            {
                using (var httpWebClient = new HttpWebClient())
                {
                    var address = "https://qun.qq.com/cgi-bin/qun_mgr/get_group_list";
                    var s       = $"bkn={Bkn}";
                    httpWebClient.Headers["Accept"]           = "application/json, text/javascript, */*; q=0.01";
                    httpWebClient.Headers["Referer"]          = "http://qun.qq.com/member.html";
                    httpWebClient.Headers["X-Requested-With"] = "XMLHttpRequest";
                    httpWebClient.Headers.Add("Cache-Control: no-cache");
                    httpWebClient.Headers["User-Agent"] = UA;
                    httpWebClient.Cookies = QunCookies;
                    var text = Encoding.UTF8.GetString(httpWebClient.UploadData(address, "POST",
                                                                                Encoding.UTF8.GetBytes(s)));

                    MessageLog("获取群列表成功:" + text);

                    var Groups = JsonConvert.DeserializeObject <GroupList>(text);
                    if (Groups.Create != null)
                    {
                        foreach (var item in Groups.Create)
                        {
                            item.Members = Search_Group_Members((long)item.Gc);
                        }
                    }

                    if (Groups.Join != null)
                    {
                        foreach (var item in Groups.Join)
                        {
                            item.Members = Search_Group_Members((long)item.Gc);
                        }
                    }

                    if (Groups.Manage != null)
                    {
                        foreach (var item in Groups.Manage)
                        {
                            item.Members = Search_Group_Members((long)item.Gc);
                        }
                    }

                    return(Groups);
                }
            }
            catch (Exception ex)
            {
                MessageLog("获取群列表失败:" + ex.Message);
            }

            return(null);
        }
コード例 #4
0
ファイル: QQUser.cs プロジェクト: kilingzhang/PCQQ-Protocol
        public GroupMembers Search_Group_Members(long ExternalId)
        {
            try
            {
                using (var httpWebClient = new HttpWebClient())
                {
                    var address = "https://qun.qq.com/cgi-bin/qun_mgr/search_group_members";
                    var s       = $"gc={ExternalId}&st=0&end=10000&sort=0&bkn={Bkn}";
                    httpWebClient.Headers["Accept"]           = "application/json, text/javascript, */*; q=0.01";
                    httpWebClient.Headers["Referer"]          = "http://qun.qq.com/member.html";
                    httpWebClient.Headers["X-Requested-With"] = "XMLHttpRequest";
                    httpWebClient.Headers.Add("Cache-Control: no-cache");
                    httpWebClient.Headers["User-Agent"] = UA;
                    httpWebClient.Cookies = QunCookies;
                    var text = Encoding.UTF8.GetString(httpWebClient.UploadData(address, "POST",
                                                                                Encoding.UTF8.GetBytes(s)));

                    var r = new Regex("\"[0-9]+\":\"[^\"]+\"");
                    if (r.IsMatch(text))
                    {
                        foreach (var match in r.Matches(text))
                        {
                            var str      = ((Capture)match).Value.Split(':');
                            var r2       = new Regex("\"[0-9]+\"");
                            var Level    = r2.Matches(str[0])[0].Value;
                            var r3       = new Regex("\"[^\"]+\"");
                            var Name     = r3.Matches(str[1])[0].Value;
                            var DataItem = "{\"level\":" + Level + ",\"name\":" + Name + "}";

                            text = text.Replace(((Capture)match).Value, DataItem);
                        }

                        text = text.Replace("\"levelname\":{", "\"levelname\":[")
                               .Replace("},\"max_count\"", "],\"max_count\"");
                    }

                    MessageLog($"获取群{ExternalId}成员列表成功:{text}");
                    return(JsonConvert.DeserializeObject <GroupMembers>(text));
                }
            }
            catch (Exception ex)
            {
                MessageLog($"获取群{ExternalId}成员列表失败:{ex.Message}");
            }

            return(null);
        }
コード例 #5
0
        /// <summary>
        ///     上传图片
        /// </summary>
        /// <param name="groupNum"></param>
        /// <param name="ukey"></param>
        /// <param name="fileName"></param>
        public void HttpUpLoadGroupImg(long groupNum, string ukey, string fileName)
        {
            using (var webclient = new HttpWebClient())
            {
                var file     = new Bitmap(fileName);
                var picBytes = ImageHelper.ImageToBytes(file);

                var apiUrl =
                    $"http://htdata2.qq.com/cgi-bin/httpconn?htcmd=0x6ff0071&ver={_user.TXProtocol.DwClientVer}&term=pc&ukey={ukey}&filesize={picBytes.Length}&range=0&uin{_user.QQ}&&groupcode={groupNum}";
                webclient.Headers["User-Agent"] = "QQClient";
                webclient.Headers.Add("Content-Type", "text/octet");
                var result = webclient.UploadData(apiUrl, "POST",
                                                  picBytes);

                file.Dispose();
            }
        }
コード例 #6
0
        public byte[] Fetch(string problemID)
        {
            string body = CreateRequestBody(problemID);

            return(_httpClient.UploadData(_config.TestDataFetchUrl, body, 3));
        }
コード例 #7
0
ファイル: TestDataFetcher.cs プロジェクト: jameschen00/sdnuoj
        private byte[] GetTestDataFile(int pid, string fileName)
        {
            string body = "gettestdata=1&filename=" + pid + "/" + fileName;

            return(_webClient.UploadData(_config.TaskFetchUrl, body, 3));
        }