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 |
| --- | --------- |
| 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 |
| data | URL Encode |
| 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:
0 正常
1100 登出微信
1100 失败/登出微信
selector:
0 正常
2 新的消息
+10 -1
View File
@@ -50,6 +50,7 @@ class WebWeixin(object):
self.ContactList = []
self.GroupList = []
self.autoReplyMode = False
self.syncHost = ''
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookielib.CookieJar()))
urllib2.install_opener(opener)
@@ -179,6 +180,13 @@ class WebWeixin(object):
# blabla ...
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):
params = {
'r': int(time.time()),
@@ -189,7 +197,7 @@ class WebWeixin(object):
'synckey': self.synckey,
'_': 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)
pm = re.search(r'window.synccheck={retcode:"(\d+)",selector:"(\d+)"}', data)
retcode = pm.group(1)
@@ -304,6 +312,7 @@ class WebWeixin(object):
def listenMsgMode(self):
print '[*] 进入消息监听模式 ... 成功'
self._run('[*] 进行同步线路测试 ... ', self.testsynccheck)
playWeChat = 0
while True:
[retcode, selector] = self.synccheck()