-
3天结束,webQQ客户端开发包,python2编写,封装了webQQ的几乎完整的功能,你可以用来开发聊天机器人,甚至更多创造性的功能。项目代码托管在Github,github.com/HotIce0/webqq-client-sdk
-
下面是没有整理的webQQ协议分析
-
关键:获取webqq的数据处理协议(js代码,从其中可以找到数据的含义,以及数据请求,数据处理)
直接访问:https://web2.qq.com/js/mq.js?t=20161220
获取数据的CGI
var GET_USER_FRIENDS_CGI = mq.STATIC_CGI_URL + “api/get_user_friends2”,
GET_GROUP_CGI = mq.STATIC_CGI_URL + “api/get_group_name_list_mask2”,
GET_DISCUSS_CGI = mq.STATIC_CGI_URL + “api/get_discus_list”,
GET_RECENT_LIST_CGI = mq.DYNAMIC_CGI_URL + “channel/get_recent_list2”,
GET_SIGNATURE = mq.STATIC_CGI_URL + “api/get_single_long_nick2”,
GET_SELF_INFO = mq.STATIC_CGI_URL + “api/get_self_info2”,
GET_GROUP_INFO_CGI_LIST = mq.STATIC_CGI_URL + “api/get_group_info_ext2”,
GET_DISCUSS_INFO_CGI_LIST = mq.DYNAMIC_CGI_URL + “channel/get_discu_info”,
GET_FRIEND_INFO_CGI = mq.STATIC_CGI_URL + “api/get_friend_info2”,
// GET_FRIEND_UIN = mq.STATIC_CGI_URL + “api/get_friend_uin2”, 这个有安全风险,已停止,20170414vorshen
GET_ONLINE_BUDDIES = mq.DYNAMIC_CGI_URL + “channel/get_online_buddies2”,
SEND_CHANGE_ONLINE_STATE = mq.DYNAMIC_CGI_URL + “channel/change_status2”
发送消息的CGI
var SEND_MSG_CGI = mq.DYNAMIC_CGI_URL + “channel/send_buddy_msg2”;
//发送群友CGI
// var SEND_SESS_CGI = mq.DYNAMIC_CGI_URL + “channel/send_sess_msg2”;这个也被停止使用了,测试无效
var SEND_GROUP_MSG_CGI = mq.DYNAMIC_CGI_URL + “channel/send_qun_msg2”;
var SEND_DISCUSS_MSG_CGI = mq.DYNAMIC_CGI_URL + “channel/send_discu_msg2”;
#陌生人的聊天
var SEND_GET_SESS_SIGN_CGI = mq.DYNAMIC_CGI_URL + “channel/get_c2cmsg_sig2”;
聊天记录的CGI
var GET_RECORD_CGI = “https://web2.qq.com/cgi-bin/webqq_chat/”;
// 根据uin获取头像
this.getAvatar = function(uin, type){
type = type || 1; // 群图标为 4
var t = mq.vfwebqq;
return ‘https://face’+(uin%10)+’.web.qq.com/cgi/svr/face/getface?cache=1&type=’+type+’&f=40&uin=’+uin+’&t=’+Math.floor(new Date()/1000)+’&vfwebqq=’+t;
};
this.getSelfAvatar = function(uin) {
return 'https://q.qlogo.cn/g?b=qq&nk=' + uin + '&s=100&t=' + Date.now();
};
var messageList = {
‘con_friends’: [‘好友’, ‘Friends’],
‘con_groups’: [‘群’, ‘Groups’],
‘con_discus’: [‘讨论组’, ‘Discussion’],
‘return’: [‘返回’, ‘Back’],
‘close’: [‘关闭’, ‘Close’],
‘unname’: [‘未命名’, ‘Unnamed’],
‘session’: [‘会话’, ‘Chats’],
‘contact’: [‘联系人’, ‘Contacts’],
‘setting’: [‘设置’, ‘Settings’],
‘plugin’: [‘发现’, ‘Discover’],
‘send’: [‘发送’, ‘Send’],
‘cancel’: [‘取消’, ‘Cancel’],
‘search’: [‘搜索’, ‘Search’],
‘members’:[‘成员’, ‘Members’],
‘record’: [‘聊天记录’, ‘Chat History’],
‘noRecord’: [‘暂无聊天记录’, ‘No Chat Records’],
‘sendMsg’: [‘发消息’, ‘Send Message’],
‘beforeclose’:[‘您确定要离开吗?’, 'Are you sure you want to leave this page? '],
//详细资料
‘profile’: [‘详细资料’, ‘Profile’],
‘signature’: ['个性签名: ', "What’s Up: "],
‘publish’: [‘公告’, ‘Notice’],
‘gender’: [‘性别’, ‘Gender’],
‘male’: [‘男’, ‘Male’],
‘female’: [‘女’, ‘Female’],
‘unknown’: [‘未知’, ‘Unknown’],
‘birthday’: [‘生日’,‘Birthday’],
‘country’: [‘国家’,‘Country’],
‘province’: [‘省份’,‘Province’],
‘city’: [‘城市’,‘City’],
‘phone’: [‘电话’,‘Phone’],
‘mobile’: [‘手机’, ‘Mobile’],
‘email’: [‘电子邮箱’, ‘Email’],
‘group_member’: [‘群成员’, ‘Group Members’],
‘group_profile’: [‘群资料’, ‘Group Profile’],
‘group_profile’: [‘群资料’, ‘Group Profile’],
‘discuss_member’:[‘讨论组成员’, ‘Discussion Members’],
‘discuss_profile’: [‘讨论组资料’, ‘Discussion Profile’],
‘buddy_unit’: [‘人’, ‘people’],
//设置 setting
‘account’: [‘帐号’, ‘Account’],
‘about_qq’: [‘关于QQ’, ‘About’],
‘loginout’: [‘退出当前帐号’, ‘Log Out’],
‘place’: [‘所在地’,‘Location’],
‘version’: [‘当前版本’, ‘Version’],
‘current_version’: ‘V1.0’,
‘service’: [‘服务条款’, ‘Terms’],
‘help’: [‘帮助与反馈’, ‘Feedback’],
‘notify_setting’: [‘消息相关设置’, ‘Notify Setting’],
‘voice’: [‘声音’, ‘Voice’],
‘notification’: [‘消息浮窗’, ‘Notifications’],
‘https_setting’: [‘HTTPS’, ‘HTTPS’],
‘https_msg’: [‘使用 HTTPS 加密聊天内容’, ‘Encrypt records via HTTPS’],
‘send_msg_way’: [‘按Ctrl+Enter键发送消息’, ‘Send Message by pressing “Ctrl” + “Enter”’],
//plugin
‘qzone’: [‘QQ空间’,‘Qzone’],
‘qmail’: [‘QQ邮箱’, ‘QQ Mail’],
‘qq_portal’: [‘腾讯网’, ‘QQ.com’],
‘soso_map’: [‘soso地图’,‘soso Maps’],
//在线状态
‘online’: [‘在线’, ‘Online’],
‘offline’: [‘离线’, ‘Offline’],
‘away’: [‘离开’, ‘Away’],
‘hidden’: [‘隐身’,‘Invisible’],
‘busy’: [‘忙碌’, ‘Busy’],
‘callme’: [‘Q我’, ‘Q Me’],
‘silent’: [‘静音’,‘Silence’],
// 表情
‘cface’: [‘自定义表情’, ‘Custom Avatars’]
};
var code2stateMap = {10:'online',20:'offline',30:'away',40:'hidden',50:'busy',60:'callme',70:'silent'};
this.code2state = function(code) {
return code2stateMap[code] || 'online';
};
var state2codeMap = {'online':10,'offline':20,'away':30,'hidden':40,'busy':50,'callme':60,'silent':70};
this.state2code = function(code) {
return state2codeMap[code] || 0;
};
1.获取快捷登陆二维码
GET