From a6d3a078a21236ebc0f1e56d8207310047e3962b Mon Sep 17 00:00:00 2001 From: Urinx <1336006643@qq.com> Date: Thu, 20 Oct 2016 11:53:14 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"=E4=BF=AE=E6=94=B9=E5=8F=91=E9=80=81?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=B6=88=E6=81=AF=E5=92=8C=E8=A1=A8=E6=83=85?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E3=80=81=E4=BD=BF=E7=94=A8=E6=9C=80=E6=96=B0=E7=BD=91=E9=A1=B5?= =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=9F=9F=E5=90=8D"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- weixin.py | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/weixin.py b/weixin.py index 953397f..1e1834b 100755 --- a/weixin.py +++ b/weixin.py @@ -81,8 +81,8 @@ class WebWeixin(object): def __init__(self): self.DEBUG = False self.uuid = '' - self.base_uri = 'https://wx.qq.com/cgi-bin/mmwebwx-bin' - self.redirect_uri = 'https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpag' + self.base_uri = '' + self.redirect_uri = '' self.uin = '' self.sid = '' self.skey = '' @@ -133,7 +133,7 @@ class WebWeixin(object): self.autoOpen = config['autoOpen'] def getUUID(self): - url = 'https://login.wx.qq.com/jslogin' + url = 'https://login.weixin.qq.com/jslogin' params = { 'appid': self.appid, 'fun': 'new', @@ -168,7 +168,7 @@ class WebWeixin(object): def waitForLogin(self, tip=1): time.sleep(tip) - url = 'https://login.wx.qq.com/cgi-bin/mmwebwx-bin/login?tip=%s&uuid=%s&_=%s' % ( + url = 'https://login.weixin.qq.com/cgi-bin/mmwebwx-bin/login?tip=%s&uuid=%s&_=%s' % ( tip, self.uuid, int(time.time())) data = self._get(url) pm = re.search(r'window.code=(\d+);', data) @@ -245,7 +245,7 @@ class WebWeixin(object): def webwxgetcontact(self): SpecialUsers = self.SpecialUsers - #print self.base_uri + print self.base_uri url = self.base_uri + '/webwxgetcontact?pass_ticket=%s&skey=%s&r=%s' % ( self.pass_ticket, self.skey, int(time.time())) dic = self._post(url, {}) @@ -313,14 +313,13 @@ class WebWeixin(object): def testsynccheck(self): SyncHost = [ - #'webpush.weixin.qq.com', - #'webpush2.weixin.qq.com', - #'webpush.wechat.com', - #'webpush1.wechat.com', - #'webpush2.wechat.com', - #'webpush1.wechatapp.com', + 'webpush.weixin.qq.com', + 'webpush2.weixin.qq.com', + 'webpush.wechat.com', + 'webpush1.wechat.com', + 'webpush2.wechat.com', + 'webpush1.wechatapp.com', # 'webpush.wechatapp.com' - 'webpush.wx.qq.com' ] for host in SyncHost: self.syncHost = host @@ -391,7 +390,7 @@ class WebWeixin(object): return dic['BaseResponse']['Ret'] == 0 def webwxuploadmedia(self, image_name): - url = 'https://file.wx.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json' + url = 'https://file2.wx.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json' # 计数器 self.media_count = self.media_count + 1 # 文件名 @@ -451,9 +450,9 @@ class WebWeixin(object): 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': 'en-US,en;q=0.5', 'Accept-Encoding': 'gzip, deflate', - 'Referer': 'https://wx.qq.com/', + 'Referer': 'https://wx2.qq.com/', 'Content-Type': multipart_encoder.content_type, - 'Origin': 'https://wx.qq.com', + 'Origin': 'https://wx2.qq.com', 'Connection': 'keep-alive', 'Pragma': 'no-cache', 'Cache-Control': 'no-cache' @@ -466,8 +465,7 @@ class WebWeixin(object): return None def webwxsendmsgimg(self, user_id, media_id): - url = self.base_uri + \ - '/webwxsendmsgimg?fun=async&f=json&pass_ticket=%s' % self.pass_ticket + url = 'https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxsendmsgimg?fun=async&f=json&pass_ticket=%s' % self.pass_ticket clientMsgId = str(int(time.time() * 1000)) + \ str(random.random())[:5].replace('.', '') data_json = { @@ -488,8 +486,7 @@ class WebWeixin(object): return dic['BaseResponse']['Ret'] == 0 def webwxsendmsgemotion(self, user_id, media_id): - url = self.base_uri + \ - '/webwxsendemoticon?fun=sys&f=json&pass_ticket=%s' % self.pass_ticket + url = 'https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxsendemoticon?fun=sys&f=json&pass_ticket=%s' % self.pass_ticket clientMsgId = str(int(time.time() * 1000)) + \ str(random.random())[:5].replace('.', '') data_json = {