Esempio n. 1
0
        public static void getGroup()
        {
            string url      = "http://s.web2.qq.com/api/get_group_name_list_mask2";
            string sendData = string.Format("r={{\"vfwebqq\":\"{0}\",\"hash\":\"{1}\"}}", vfwebqq, hash);
            string dat      = HTTP.HttpPost(url, "http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1", sendData, Encoding.UTF8, true);

            Program.formlogin.textBoxLog.Text = dat;

            Program.formlogin.group = (JsonGroupModel)JsonConvert.DeserializeObject(dat, typeof(JsonGroupModel));
            int i;

            for (i = 0; i < Program.formlogin.group.result.gnamelist.Count; i++)
            {
                bool Already = false;
                for (int j = 0; j < Program.formlogin.groupinfMaxIndex; j++)
                {
                    if (Program.formlogin.groupinfo[j].gid.Equals(Program.formlogin.group.result.gnamelist[i].gid))
                    {
                        Already = true;
                    }
                }
                if (!Already)
                {
                    Program.formlogin.listBoxGroup.Items.Add(Program.formlogin.group.result.gnamelist[i].gid + "::" + Program.formlogin.group.result.gnamelist[i].name);
                    Program.formlogin.groupinfo[Program.formlogin.groupinfMaxIndex].gid = Program.formlogin.group.result.gnamelist[i].gid;
                    Program.formlogin.groupinfo[Program.formlogin.groupinfMaxIndex].inf = GetGroupInfo(Program.formlogin.group.result.gnamelist[i].code);
                    Program.formlogin.groupinfMaxIndex++;
                }
            }
        }
Esempio n. 2
0
        public static void getFrienf()
        {
            string url      = "http://s.web2.qq.com/api/get_user_friends2";
            string sendData = string.Format("r={{\"vfwebqq\":\"{0}\",\"hash\":\"{1}\"}}", vfwebqq, hash);
            string dat      = HTTP.HttpPost(url, "http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1", sendData, Encoding.UTF8, true);

            Program.formlogin.textBoxLog.Text = dat;

            Program.formlogin.user = (JsonFriendModel)JsonConvert.DeserializeObject(dat, typeof(JsonFriendModel));
            for (int i = 0; i < Program.formlogin.user.result.info.Count; i++)
            {
                bool flag = false;
                for (int j = 0; j <= Program.formlogin.friendinfMaxIndex; j++)
                {
                    if (Program.formlogin.friendinf[j].uin == Program.formlogin.user.result.info[i].uin)
                    {
                        flag = true;
                        break;
                    }
                }
                if (flag)
                {
                    continue;
                }
                else
                {
                    Program.formlogin.friendinfMaxIndex++;
                    Program.formlogin.friendinf[Program.formlogin.friendinfMaxIndex].uin = Program.formlogin.user.result.info[i].uin;
                    Program.formlogin.listBoxFriend.Items.Add(Program.formlogin.user.result.info[i].uin + ":" + GetRealQQ(Program.formlogin.user.result.info[i].uin) + ":" + Program.formlogin.user.result.info[i].nick);
                }
            }
        }
Esempio n. 3
0
        /// 发送群消息
        public static bool SendMessageToGroup(string gin, string content)
        {
            if (content.Equals(""))
            {
                return(false);
            }
            if (gin.Equals(""))
            {
                return(false);
            }
            MsgId++;
            content = content.Replace("\r\n", "\n");
            content = content.Replace("\n\r", "\n");
            content = content.Replace("\r", "\n");
            content = content.Replace("\n", Environment.NewLine);
            try
            {
                string postData = "{\"group_uin\":" + gin
                                  + ",\"content\":\"[" + content.Replace(Environment.NewLine, "\\\\n")
                                  + ",[\\\"font\\\",{\\\"name\\\":\\\"宋体\\\",\\\"size\\\":11,\\\"style\\\":[0,0,0],\\\"color\\\":\\\"00FF00\\\"}]]\",\"face\":0,\"clientid\":" + ClientID
                                  + ",\"msg_id\":" + MsgId
                                  + ",\"psessionid\":\"" + psessionid
                                  + "\"}";
                postData = "r=" + HttpUtility.UrlEncode(postData);

                string referer = "http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2";
                string url     = "http://d1.web2.qq.com/channel/send_qun_msg2";

                string dat = HTTP.HttpPost(url, referer, postData, Encoding.UTF8, false);

                dat = dat.Replace("{\"retcode\":", "");
                dat = dat.Replace("\"result\":\"", "");
                dat = dat.Replace("\"}", "");
                string[] tmp = dat.Split(',');
                if (tmp[0] == "0" && tmp[0] == "ok")
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }
Esempio n. 4
0
        public static void SecondLogin()
        {
            //二次登录
            string url = "http://d1.web2.qq.com/channel/login2";

            string url1 = "{\"ptwebqq\":\"" + ptwebqq + "\",\"clientid\":" + ClientID + ",\"psessionid\":\"\",\"status\":\"online\"}";

            url1 = "r=" + HttpUtility.UrlEncode(url1);
            string dat = HTTP.HttpPost(url, "http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2", url1, Encoding.UTF8, true);

            Program.formlogin.textBoxLog.Text = dat;
            char[] t = new char[2];
            t[0] = ':';
            t[1] = ',';
            dat  = dat.Replace("{", "");
            dat  = dat.Replace("}", "");
            dat  = dat.Replace("\"", "");
            string[] tmp = dat.Split(t);

            psessionid = tmp[10];
            hash       = GetHash(Program.formlogin.QQNum, ptwebqq);
        }
Esempio n. 5
0
        //http://www.cnblogs.com/lianmin/p/4257421.html
        /// 发送好友消息
        public static bool SendMessageToFriend(string uid, string content, string specialMessage = "")
        {
            if (content.Equals(""))
            {
                return(false);
            }
            if (uid.Equals(""))
            {
                return(false);
            }
            string[] temp = specialMessage.Split(',');;
            MsgId++;
            content = content.Replace("\r\n", "\n");
            content = content.Replace("\n\r", "\n");
            content = content.Replace("\r", "\n");
            content = content.Replace("\n", Environment.NewLine);
            try
            {
                string postData = "";
                if (temp[0] != "disscuss")
                {
                    postData = "{\"to\":" + uid;
                }
                else
                {
                    postData = "{\"did\":" + uid;
                }
                postData += ",\"content\":\"[" + content.Replace(Environment.NewLine, "\\\\n");
                postData += ",[\\\"font\\\",{\\\"name\\\":\\\"宋体\\\",\\\"size\\\":10,\\\"style\\\":[0,0,0],\\\"color\\\":\\\"000000\\\"}]]\",\"clientid\":" + ClientID + ",\"face\":";
                postData += "0";
                postData += ",\"msg_id\":" + MsgId;
                postData += ",\"psessionid\":\"" + psessionid + "\"";

                if (temp[0] != "" && temp[0] != "disscuss")
                {
                    postData += ",\"group_sig\":\"" + GetGroupSig(temp[0], temp[1], temp[2]);
                    postData += "\",\"service_type\":" + temp[2];
                }
                postData += "}";
                string url;
                string referer = "http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2";
                if (specialMessage == "")
                {
                    url = "http://d1.web2.qq.com/channel/send_buddy_msg2";
                }
                else if (temp[0] == "disscuss")
                {
                    url = "http://d1.web2.qq.com/channel/send_discu_msg2";
                }
                else
                {
                    url = "http://d1.web2.qq.com/channel/send_sess_msg2";
                }
                postData = "r=" + HttpUtility.UrlEncode(postData);

                string dat = HTTP.HttpPost(url, referer, postData, Encoding.UTF8, false);

                dat = dat.Replace("{\"retcode\":", "");
                dat = dat.Replace("\"result\":\"", "");
                dat = dat.Replace("\"}", "");
                string[] tmp = dat.Split(',');
                if (tmp[0] == "0" && tmp[0] == "ok")
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }