fix synccheck bug

This commit is contained in:
urinx
2016-02-04 23:35:29 +08:00
parent 2aaa20c7e8
commit f1cfebd800
2 changed files with 12 additions and 3 deletions
+2 -2
View File
@@ -285,7 +285,7 @@ window.redirect_uri="https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage?tic
| API | synccheck | | API | synccheck |
| --- | --------- | | --- | --------- |
| url | https://webpush.weixin.qq.com/cgi-bin/mmwebwx-bin/synccheck | | url | https://webpush.weixin.qq.com/cgi-bin/mmwebwx-bin/synccheck or <br> https://webpush2.weixin.qq.com/cgi-bin/mmwebwx-bin/synccheck |
| method | GET | | method | GET |
| data | URL Encode | | data | URL Encode |
| params | **r**: `时间戳` <br> **sid**: xxx <br> **uin**: xxx <br> **skey**: xxx <br> **deviceid**: xxx <br> **synckey**: xxx <br> **_**: `时间戳` | | params | **r**: `时间戳` <br> **sid**: xxx <br> **uin**: xxx <br> **skey**: xxx <br> **deviceid**: xxx <br> **synckey**: xxx <br> **_**: `时间戳` |
@@ -296,7 +296,7 @@ window.synccheck={retcode:"xxx",selector:"xxx"}
retcode: retcode:
0 正常 0 正常
1100 登出微信 1100 失败/登出微信
selector: selector:
0 正常 0 正常
2 新的消息 2 新的消息
+10 -1
View File
@@ -50,6 +50,7 @@ class WebWeixin(object):
self.ContactList = [] self.ContactList = []
self.GroupList = [] self.GroupList = []
self.autoReplyMode = False self.autoReplyMode = False
self.syncHost = ''
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookielib.CookieJar())) opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookielib.CookieJar()))
urllib2.install_opener(opener) urllib2.install_opener(opener)
@@ -179,6 +180,13 @@ class WebWeixin(object):
# blabla ... # blabla ...
return True return True
def testsynccheck(self):
for host in ['webpush', 'webpush2']:
self.syncHost = host
[retcode, selector] = self.synccheck()
if retcode == '0': return True
return False
def synccheck(self): def synccheck(self):
params = { params = {
'r': int(time.time()), 'r': int(time.time()),
@@ -189,7 +197,7 @@ class WebWeixin(object):
'synckey': self.synckey, 'synckey': self.synckey,
'_': int(time.time()), '_': int(time.time()),
} }
url = 'https://webpush.weixin.qq.com/cgi-bin/mmwebwx-bin/synccheck?' + urllib.urlencode(params) url = 'https://' + self.syncHost + '.weixin.qq.com/cgi-bin/mmwebwx-bin/synccheck?' + urllib.urlencode(params)
data = self._get(url) data = self._get(url)
pm = re.search(r'window.synccheck={retcode:"(\d+)",selector:"(\d+)"}', data) pm = re.search(r'window.synccheck={retcode:"(\d+)",selector:"(\d+)"}', data)
retcode = pm.group(1) retcode = pm.group(1)
@@ -304,6 +312,7 @@ class WebWeixin(object):
def listenMsgMode(self): def listenMsgMode(self):
print '[*] 进入消息监听模式 ... 成功' print '[*] 进入消息监听模式 ... 成功'
self._run('[*] 进行同步线路测试 ... ', self.testsynccheck)
playWeChat = 0 playWeChat = 0
while True: while True:
[retcode, selector] = self.synccheck() [retcode, selector] = self.synccheck()