C#模拟手机QQ 发送QQ消息(QQhttp1.4协议)

详细代码如下(代码参考网上他人代码修改的,不完全相同):
private void button1_Click(object sender, EventArgs e)
        {
            //string SEQ = DateTime.Now.Ticks.ToString().Substring(7, 7);
            string QqNum = "1319333759";//用来发送QQ消息的QQ
            string QqPwd = "413C570DDD92A9983C8FECEB7385594D";//MD5加密413c570ddd92a9983c8feceb7385594d 
            string Msg = "测试QQ发送消息";
            string strLogin = "VER=1.4&CON=1&CMD=Login&SEQ=" + GetSjs3Byte() + "&UIN=" + QqNum + "&PS=" + QqPwd + "&M5=1&LG=0&LC=812822641C978097&GD=TW00QOJ9KUVD753S&CKE=\n";
            Console.WriteLine("登录状况:" + Post(strLogin));
            string receiveQQ="709334572";//接收消息的QQ,注意这个QQ需要与发送消息的QQ是好友关系,否则发送接收不到的。
            string strMsg = "VER=1.4&CON=1&CMD=CLTMSG&SEQ=" + GetSjs3Byte() + "&UIN=" + QqNum + "&SID=&XP=C4CA4238A0B92382&UN=" +receiveQQ+"&MG=" + Msg;
            Console.WriteLine("发送消息结果:" + Post(strMsg));
        }
        /// 
        /// 获取200到299的随机数
        /// 
        /// 
        public string GetSjs3Byte()
        {
            Random rnd = new Random();
            int i = rnd.Next(200, 999);
            return i.ToString();
        }
        public static string Post(string postValues)
        {
            string Host = "http://119.147.14.253:14000";
            WebClient _client = new WebClient();
            Byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(postValues);
            Byte[] pageData = _client.UploadData(Host, "POST", byteArray);

            string returnVal = Encoding.UTF8.GetString(pageData);
            return returnVal;
        }

你可能感兴趣的:(C#模拟手机QQ 发送QQ消息(QQhttp1.4协议))