Skip to content

Commit 807d7bb

Browse files
committed
新增获取最新消息
1 parent f7c60ea commit 807d7bb

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

webqq/client.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,21 @@ def get_friends_account(friends_uin):
313313
def get_new_msg():
314314
"""
315315
获取最新消息(轮询)
316+
备注:请求到返回时间大概10S
317+
可以用死循环模拟轮询
316318
"""
317-
pass
319+
new_msg_url = 'http://d.web2.qq.com/channel/poll2'
320+
header['Host'] = 'd.web2.qq.com'
321+
header['Referer'] = 'http://d.web2.qq.com/proxy.html?v=20130916001&callback=1&id=2'
322+
new_msg_dict = {
323+
"ptwebqq": ptwebqq,
324+
"clientid": ClientID,
325+
"psessionid": PSessionID,
326+
"key": ""
327+
}
328+
new_msg_payload = {'r': json.dumps(new_msg_dict)}
329+
response = s.post(new_msg_url, data=new_msg_payload, headers=header)
330+
return json.loads(response.content)
318331

319332

320333
if __name__ == "__main__":

0 commit comments

Comments
 (0)