Skip to content
This repository was archived by the owner on Dec 24, 2018. It is now read-only.

Commit fd89f8d

Browse files
authored
Merge pull request Urinx#105 from lbbniu/master
修改发送图片消息和表情消息失败的问题、使用最新网页微信域名
2 parents 9eaddb1 + bc0482c commit fd89f8d

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

weixin.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ def __str__(self):
8181
def __init__(self):
8282
self.DEBUG = False
8383
self.uuid = ''
84-
self.base_uri = ''
85-
self.redirect_uri = ''
84+
self.base_uri = 'https://wx.qq.com/cgi-bin/mmwebwx-bin'
85+
self.redirect_uri = 'https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpag'
8686
self.uin = ''
8787
self.sid = ''
8888
self.skey = ''
@@ -133,7 +133,7 @@ def loadConfig(self, config):
133133
self.autoOpen = config['autoOpen']
134134

135135
def getUUID(self):
136-
url = 'https://login.weixin.qq.com/jslogin'
136+
url = 'https://login.wx.qq.com/jslogin'
137137
params = {
138138
'appid': self.appid,
139139
'fun': 'new',
@@ -168,7 +168,7 @@ def _showQRCodeImg(self):
168168

169169
def waitForLogin(self, tip=1):
170170
time.sleep(tip)
171-
url = 'https://login.weixin.qq.com/cgi-bin/mmwebwx-bin/login?tip=%s&uuid=%s&_=%s' % (
171+
url = 'https://login.wx.qq.com/cgi-bin/mmwebwx-bin/login?tip=%s&uuid=%s&_=%s' % (
172172
tip, self.uuid, int(time.time()))
173173
data = self._get(url)
174174
pm = re.search(r'window.code=(\d+);', data)
@@ -245,7 +245,7 @@ def webwxstatusnotify(self):
245245

246246
def webwxgetcontact(self):
247247
SpecialUsers = self.SpecialUsers
248-
print self.base_uri
248+
#print self.base_uri
249249
url = self.base_uri + '/webwxgetcontact?pass_ticket=%s&skey=%s&r=%s' % (
250250
self.pass_ticket, self.skey, int(time.time()))
251251
dic = self._post(url, {})
@@ -313,13 +313,14 @@ def getNameById(self, id):
313313

314314
def testsynccheck(self):
315315
SyncHost = [
316-
'webpush.weixin.qq.com',
317-
'webpush2.weixin.qq.com',
318-
'webpush.wechat.com',
319-
'webpush1.wechat.com',
320-
'webpush2.wechat.com',
321-
'webpush1.wechatapp.com',
316+
#'webpush.weixin.qq.com',
317+
#'webpush2.weixin.qq.com',
318+
#'webpush.wechat.com',
319+
#'webpush1.wechat.com',
320+
#'webpush2.wechat.com',
321+
#'webpush1.wechatapp.com',
322322
# 'webpush.wechatapp.com'
323+
'webpush.wx.qq.com'
323324
]
324325
for host in SyncHost:
325326
self.syncHost = host
@@ -390,7 +391,7 @@ def webwxsendmsg(self, word, to='filehelper'):
390391
return dic['BaseResponse']['Ret'] == 0
391392

392393
def webwxuploadmedia(self, image_name):
393-
url = 'https://file2.wx.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json'
394+
url = 'https://file.wx.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json'
394395
# 计数器
395396
self.media_count = self.media_count + 1
396397
# 文件名
@@ -450,9 +451,9 @@ def webwxuploadmedia(self, image_name):
450451
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
451452
'Accept-Language': 'en-US,en;q=0.5',
452453
'Accept-Encoding': 'gzip, deflate',
453-
'Referer': 'https://wx2.qq.com/',
454+
'Referer': 'https://wx.qq.com/',
454455
'Content-Type': multipart_encoder.content_type,
455-
'Origin': 'https://wx2.qq.com',
456+
'Origin': 'https://wx.qq.com',
456457
'Connection': 'keep-alive',
457458
'Pragma': 'no-cache',
458459
'Cache-Control': 'no-cache'
@@ -465,7 +466,8 @@ def webwxuploadmedia(self, image_name):
465466
return None
466467

467468
def webwxsendmsgimg(self, user_id, media_id):
468-
url = 'https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxsendmsgimg?fun=async&f=json&pass_ticket=%s' % self.pass_ticket
469+
url = self.base_uri + \
470+
'/webwxsendmsgimg?fun=async&f=json&pass_ticket=%s' % self.pass_ticket
469471
clientMsgId = str(int(time.time() * 1000)) + \
470472
str(random.random())[:5].replace('.', '')
471473
data_json = {
@@ -486,7 +488,8 @@ def webwxsendmsgimg(self, user_id, media_id):
486488
return dic['BaseResponse']['Ret'] == 0
487489

488490
def webwxsendmsgemotion(self, user_id, media_id):
489-
url = 'https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxsendemoticon?fun=sys&f=json&pass_ticket=%s' % self.pass_ticket
491+
url = self.base_uri + \
492+
'/webwxsendemoticon?fun=sys&f=json&pass_ticket=%s' % self.pass_ticket
490493
clientMsgId = str(int(time.time() * 1000)) + \
491494
str(random.random())[:5].replace('.', '')
492495
data_json = {

0 commit comments

Comments
 (0)