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

Commit aae294e

Browse files
committed
✄ fix wechat read message error
1 parent cd936ca commit aae294e

File tree

16 files changed

+509
-448
lines changed

16 files changed

+509
-448
lines changed

README.md

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ wechat-robot是基于微信网页版协议开发的普通微信号机器人程
66

77
## 使用
88

9-
直接运行 `Application` 中的main函数
9+
直接运行 `me.biezhi.wechat.Application` 中的main函数
10+
11+
## 机器人接口申请地址 (申请后在config.properties文件中配置)
12+
13+
[http://www.itpk.cn/robot.php](http://www.itpk.cn/robot.php)
1014

1115
使用手机扫描二维码
1216

@@ -15,34 +19,26 @@ wechat-robot是基于微信网页版协议开发的普通微信号机器人程
1519
### 控制台日志
1620

1721
```sh
18-
2016-02-21 18:49:02,636 INFO [main] me.biezhi.weixin.App | [*] GET https://login.weixin.qq.com/jslogin?appid=wx782c26e4c19acffb&fun=new&lang=zh_CN&_=1456051742
19-
2016-02-21 18:49:03,100 INFO [main] me.biezhi.weixin.App | [*] 获取到uuid为 [QZP9RCOmVA==]
20-
2016-02-21 18:49:03,328 INFO [main] me.biezhi.weixin.App | [*] GET https://login.weixin.qq.com/cgi-bin/mmwebwx-bin/login?tip=1&uuid=QZP9RCOmVA==&_=1456051743
21-
2016-02-21 18:49:06,413 INFO [main] me.biezhi.weixin.App | [*] 成功扫描,请在手机上点击确认以登录
22-
2016-02-21 18:49:08,413 INFO [main] me.biezhi.weixin.App | [*] GET https://login.weixin.qq.com/cgi-bin/mmwebwx-bin/login?tip=1&uuid=QZP9RCOmVA==&_=1456051748
23-
2016-02-21 18:49:08,414 INFO [main] me.biezhi.weixin.App | [*] 正在登录...
24-
2016-02-21 18:49:08,414 INFO [main] me.biezhi.weixin.App | [*] redirect_uri=https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage?ticket=A4BjR97r2-55oYG23dXSucQK@qrticket_0&uuid=QZP9RCOmVA==&lang=zh_CN&scan=1456051814&fun=new
25-
2016-02-21 18:49:08,414 INFO [main] me.biezhi.weixin.App | [*] base_uri=https://wx2.qq.com/cgi-bin/mmwebwx-bin
26-
2016-02-21 18:49:08,419 INFO [main] me.biezhi.weixin.App | [*] GET https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage?ticket=A4BjR97r2-55oYG23dXSucQK@qrticket_0&uuid=QZP9RCOmVA==&lang=zh_CN&scan=1456051814&fun=new
27-
2016-02-21 18:49:08,861 INFO [main] me.biezhi.weixin.App | [*] skey[@crypt_a742d75a_9c1d3752638ef9112f0b48895e8ae69d]
28-
2016-02-21 18:49:08,861 INFO [main] me.biezhi.weixin.App | [*] wxsid[3DfEeKrrBD2r4Sn6]
29-
2016-02-21 18:49:08,861 INFO [main] me.biezhi.weixin.App | [*] wxuin[3155248292]
30-
2016-02-21 18:49:08,861 INFO [main] me.biezhi.weixin.App | [*] pass_ticket[iYBKk3bszHw1ZIUZgow4tqSZx%2BfY3ACnGlgqQI7rAJwkP%2B4iVQHdHlxT0ipK3V4N]
31-
2016-02-21 18:49:08,866 INFO [main] me.biezhi.weixin.App | [*] 微信登录成功
32-
2016-02-21 18:49:09,031 INFO [main] me.biezhi.weixin.App | [*] POST https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxinit?r=1456051748&pass_ticket=iYBKk3bszHw1ZIUZgow4tqSZx%2BfY3ACnGlgqQI7rAJwkP%2B4iVQHdHlxT0ipK3V4N&skey=@crypt_a742d75a_9c1d3752638ef9112f0b48895e8ae69d
33-
2016-02-21 18:49:09,214 INFO [main] me.biezhi.weixin.App | [*] 微信初始化成功
34-
2016-02-21 18:49:09,215 INFO [main] me.biezhi.weixin.App | [*] POST https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxstatusnotify?lang=zh_CN&pass_ticket=iYBKk3bszHw1ZIUZgow4tqSZx%2BfY3ACnGlgqQI7rAJwkP%2B4iVQHdHlxT0ipK3V4N
35-
2016-02-21 18:49:09,306 INFO [main] me.biezhi.weixin.App | [*] 开启状态通知成功
36-
2016-02-21 18:49:09,307 INFO [main] me.biezhi.weixin.App | [*] POST https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxgetcontact?pass_ticket=iYBKk3bszHw1ZIUZgow4tqSZx%2BfY3ACnGlgqQI7rAJwkP%2B4iVQHdHlxT0ipK3V4N&skey=@crypt_a742d75a_9c1d3752638ef9112f0b48895e8ae69d&r=1456051749
37-
2016-02-21 18:49:09,540 INFO [main] me.biezhi.weixin.App | [*] 获取联系人成功
38-
2016-02-21 18:49:09,540 INFO [main] me.biezhi.weixin.App | [*] 共有 4 位联系人
39-
2016-02-21 18:49:09,542 INFO [listenMsgMode] me.biezhi.weixin.App | [*] 进入消息监听模式 ...
40-
2016-02-21 18:49:09,543 INFO [listenMsgMode] me.biezhi.weixin.App | [*] GET https://webpush2.weixin.qq.com/cgi-bin/mmwebwx-bin/synccheck?r=145605174961757&skey=@crypt_a742d75a_9c1d3752638ef9112f0b48895e8ae69d&uin=3155248292&sid=3DfEeKrrBD2r4Sn6&deviceid=e1456051742&synckey=1_610390336%7C2_610390399%7C3_610390360%7C1000_1456046795&_=1456051749542
41-
2016-02-21 18:49:09,779 INFO [listenMsgMode] me.biezhi.weixin.App | [*] retcode=0,selector=2
42-
2016-02-21 18:49:09,782 INFO [listenMsgMode] me.biezhi.weixin.App | [*] POST https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxsync?lang=zh_CN&pass_ticket=iYBKk3bszHw1ZIUZgow4tqSZx%2BfY3ACnGlgqQI7rAJwkP%2B4iVQHdHlxT0ipK3V4N&skey=@crypt_a742d75a_9c1d3752638ef9112f0b48895e8ae69d&sid=3DfEeKrrBD2r4Sn6&r=1456051749
43-
2016-02-21 18:49:09,978 INFO [listenMsgMode] me.biezhi.weixin.App | [*] 你有新的消息,请注意查收
44-
2016-02-21 18:49:09,978 INFO [listenMsgMode] me.biezhi.weixin.App | [*] 成功截获微信初始化消息
45-
2016-02-21 18:49:09,978 INFO [listenMsgMode] me.biezhi.weixin.App | [*] 你有新的消息,请注意查收
22+
[wechat-robot] 2016-09-11 01:01:45,734 INFO [main] com.blade.kit.base.Config => Load config [classpath:config.properties]
23+
[wechat-robot] 2016-09-11 01:01:47,763 INFO [main] me.biezhi.wechat.WechatRobot => 获取到uuid为 [IdNRA183Nw==]
24+
[wechat-robot] 2016-09-11 01:01:47,991 INFO [main] me.biezhi.wechat.WechatRobot => 等待登录...
25+
[wechat-robot] 2016-09-11 01:01:57,180 INFO [main] me.biezhi.wechat.WechatRobot => 成功扫描,请在手机上点击确认以登录
26+
[wechat-robot] 2016-09-11 01:01:59,184 INFO [main] me.biezhi.wechat.WechatRobot => 等待登录...
27+
[wechat-robot] 2016-09-11 01:01:59,204 INFO [main] me.biezhi.wechat.WechatRobot => 正在登录...
28+
[wechat-robot] 2016-09-11 01:01:59,959 INFO [main] me.biezhi.wechat.WechatRobot => 微信登录成功
29+
[wechat-robot] 2016-09-11 01:01:59,959 INFO [main] me.biezhi.wechat.WechatRobot => 微信初始化...
30+
[wechat-robot] 2016-09-11 01:02:00,153 INFO [main] me.biezhi.wechat.WechatRobot => 微信初始化成功
31+
[wechat-robot] 2016-09-11 01:02:00,153 INFO [main] me.biezhi.wechat.WechatRobot => 开启状态通知...
32+
[wechat-robot] 2016-09-11 01:02:00,259 INFO [main] me.biezhi.wechat.WechatRobot => 开启状态通知成功
33+
[wechat-robot] 2016-09-11 01:02:00,259 INFO [main] me.biezhi.wechat.WechatRobot => 获取联系人...
34+
[wechat-robot] 2016-09-11 01:02:00,538 INFO [main] me.biezhi.wechat.WechatRobot => 获取联系人成功
35+
[wechat-robot] 2016-09-11 01:02:00,538 INFO [main] me.biezhi.wechat.WechatRobot => 共有 4 位联系人
36+
[wechat-robot] 2016-09-11 01:02:00,539 INFO [wechat-listener-thread] me.biezhi.wechat.listener.WechatListener => 进入消息监听模式 ...
37+
[wechat-robot] 2016-09-11 01:02:00,782 INFO [wechat-listener-thread] me.biezhi.wechat.service.WechatService => 选择线路:[webpush2.weixin.qq.com]
38+
[wechat-robot] 2016-09-11 01:02:00,835 INFO [wechat-listener-thread] me.biezhi.wechat.listener.WechatListener => retcode=0, selector=2
39+
[wechat-robot] 2016-09-11 01:02:01,095 INFO [wechat-listener-thread] me.biezhi.wechat.service.WechatService => 你有新的消息,请注意查收
40+
[wechat-robot] 2016-09-11 01:02:01,095 INFO [wechat-listener-thread] me.biezhi.wechat.service.WechatService => 成功截获微信初始化消息
41+
[wechat-robot] 2016-09-11 01:02:01,095 INFO [wechat-listener-thread] me.biezhi.wechat.listener.WechatListener => 等待2000ms...
4642
```
4743

4844
### 测试通信

src/main/java/config.properties

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1+
# request url : http://www.itpk.cn/robot.php
12
itpk.api_key=
2-
itpk.api_secret=
3+
itpk.api_secret=
4+
5+
# image save path
6+
app.img_path=./img

src/main/java/log4j.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
log4j.rootLogger = info, stdout
1+
log4j.rootLogger=info, stdout
22

33
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
44
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
5-
log4j.appender.stdout.layout.ConversionPattern = [wechat-robot] %d %-5p [%t] %c | %m%n
5+
log4j.appender.stdout.layout.ConversionPattern = [wechat-robot] %d %-5p[%t] %c => %m%n

src/main/java/me/biezhi/wechat/Application.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
package me.biezhi.wechat;
22

3-
/**
4-
*
5-
*/
3+
import com.blade.kit.base.Config;
4+
65
public class Application {
76

87
public static void main(String[] args) {
98
try {
9+
10+
Constant.config = Config.load("classpath:config.properties");
11+
1012
WechatRobot wechatRobot = new WechatRobot();
1113
wechatRobot.showQrCode();
12-
while(!wechatRobot.waitForLogin().equals("200")){
14+
while(!Constant.HTTP_OK.equals(wechatRobot.waitForLogin())){
1315
Thread.sleep(2000);
1416
}
1517
wechatRobot.closeQrWindow();

src/main/java/me/biezhi/wechat/Constant.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,38 @@
33
import java.util.Arrays;
44
import java.util.List;
55

6+
import com.blade.kit.base.Config;
7+
8+
import me.biezhi.wechat.model.WechatContact;
9+
610
public class Constant {
711

12+
public static final String HTTP_OK = "200";
813
public static final String BASE_URL = "https://webpush2.weixin.qq.com/cgi-bin/mmwebwx-bin";
914
public static final String JS_LOGIN_URL = "https://login.weixin.qq.com/jslogin";
1015
public static final String QRCODE_URL = "https://login.weixin.qq.com/qrcode/";
1116

1217
public static final String ITPK_API = "http://i.itpk.cn/api.php";
1318

14-
public static final List<String> SpecialUsers = Arrays.asList("newsapp", "fmessage", "filehelper", "weibo", "qqmail", "fmessage", "tmessage", "qmessage", "qqsync", "floatbottle", "lbsapp", "shakeapp", "medianote", "qqfriend", "readerapp", "blogapp", "facebookapp", "masssendapp", "meishiapp", "feedsapp", "voip", "blogappweixin", "weixin", "brandsessionholder", "weixinreminder", "wxid_novlwrv3lqwv11", "gh_22b87fa7cb3c", "officialaccounts", "notification_messages", "wxid_novlwrv3lqwv11", "gh_22b87fa7cb3c", "wxitil", "userexperience_alarm", "notification_messages");
19+
// 特殊用户 须过滤
20+
public static final List<String> FILTER_USERS = Arrays.asList("newsapp", "fmessage", "filehelper", "weibo", "qqmail",
21+
"fmessage", "tmessage", "qmessage", "qqsync", "floatbottle", "lbsapp", "shakeapp", "medianote", "qqfriend",
22+
"readerapp", "blogapp", "facebookapp", "masssendapp", "meishiapp", "feedsapp", "voip", "blogappweixin",
23+
"weixin", "brandsessionholder", "weixinreminder", "wxid_novlwrv3lqwv11", "gh_22b87fa7cb3c", "officialaccounts",
24+
"notification_messages", "wxid_novlwrv3lqwv11", "gh_22b87fa7cb3c", "wxitil", "userexperience_alarm",
25+
"notification_messages");
26+
27+
public static final String[] SYNC_HOST = {
28+
"webpush.weixin.qq.com",
29+
"webpush2.weixin.qq.com",
30+
"webpush.wechat.com",
31+
"webpush1.wechat.com",
32+
"webpush2.wechat.com",
33+
"webpush1.wechatapp.com"
34+
};
35+
36+
public static WechatContact CONTACT;
1537

38+
// 全局配置文件
39+
public static Config config;
1640
}

0 commit comments

Comments
 (0)