基于http的QQ协议代码

#转载:http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=563093


# -*- coding: cp936 -*-

"""2005-06-15
看到微程朋友分析基于http的QQ协议,于是准备写一个QQ程序。但是现在http中的有些包已经不能用了。
我只有继续使用socket的协议了。感谢微程朋友的帮助。关于协议大家可以看他的blog
http://spaces.msn.com/members/mprogramer/Blog/cns!1pKnbff3FpJuGZcrsAlNZmZQ!147.entry
本程序为MIT授权
如果需要转载本程序,请保留版权信息"""
import urllib,httplib,md5,time
class qq:
    def __init__(self):
        self.pwd=md5.new('你的QQ密码').hexdigest()
        self.headers=""
        self.qq='你的QQ号码'
        self.conn= httplib.HTTPConnection("219.133.51.11:8000")#这里是tqq.tencent.com的ip地址,也可以直接用域名


    def Login(self):#登陆
        self.headers=("VER=1.0&CMD=Login&SEQ="+\
                      str(int(time.time()*100)%(10**5))+"&UIN="+\
                      self.qq+"&PS="+\
                      self.pwd+\
                      "&M5=1&LC=9326B87B234E7235")
        
        self.conn.request("POST","", self.headers)
        response = self.conn.getresponse()                                      
        print response.read()
        
    def Query_Stat(self):#在线好友
        self.headers=("VER=1.0&CMD=Query_Stat&SEQ="+\
                      str(int(time.time()*100)%(10**5))+"&UIN="+\
                      self.qq+"&TN=50&UN=0")
                      
        self.conn.request("POST","", self.headers)
        response = self.conn.getresponse()                                      
        print response.read()
        
    def List(self):#好友列表
        self.headers=("VER=1.0&CMD=List&SEQ="+\
                      str(int(time.time()*100)%(10**5))+"&UIN="+\
                      self.qq+"TN=160&UN=0")
        
        self.conn.request("POST","", self.headers)
        response = self.conn.getresponse()                                      
        print response.read()


    def GetInfo(self):#指定QQ号码的详细内容
        self.headers=("VER=1.0&CMD=GetInfo&SEQ="+\
                      str(int(time.time()*100)%(10**5))+"&UIN="+\
                      self.qq+"&LV=2&UN=40900181")
        
        self.conn.request("POST","", self.headers)
        response = self.conn.getresponse()                                      
        print response.read()


    def AddToList(self):#增加指定QQ号码为好友
        self.headers=("VER=1.0&CMD=AddToList&SEQ="+\
                      str(int(time.time()*100)%(10**5))+"&UIN="+\
                      self.qq+"&UN=278333853")
        
        self.conn.request("POST","", self.headers)
        response = self.conn.getresponse()                                      
        print response.read()


test=qq()
test.Login()
"""不知道为什么除了Login和Logout包其他的都有问题。很郁闷"""
#test.Query_Stat()
test.List()
#test.conn.close()
#test.GetInfo()
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值