Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
f40cec5
Update README.md
binarywang Aug 1, 2016
65fb373
版本号更改为 2.1.0-SNAPSHOT
binarywang Aug 1, 2016
49d561c
优化WxError类的toString方法,避免输出重复内容
binarywang Aug 1, 2016
8b1c320
Update README.md
binarywang Aug 1, 2016
baf99d6
调整readme部分格式
binarywang Aug 1, 2016
6643498
code clean up for common module
binarywang Aug 2, 2016
f7a64a7
将菜单相关的类转移到单独的包里方便管理,以便于某些特殊需求
binarywang Aug 2, 2016
d05da57
code clean up for cp module
binarywang Aug 2, 2016
f65c6f7
Update README.md
binarywang Aug 9, 2016
8a4f1e6
卡券service构造方法改为public
ZhaoxiongTan Aug 10, 2016
6e55387
Merge pull request #19 from ZhaoxiongTan/develop
binarywang Aug 10, 2016
ccecac9
Update README.md
binarywang Aug 11, 2016
5057f2d
增加生成授权链接方法,重定向链接可直接读取配置。
gaigeshen Aug 12, 2016
c2f00a1
Merge pull request #21 from gaigeshen/develop
kareanyi Aug 12, 2016
4bd7e61
规范代码命名格式
binarywang Aug 13, 2016
a154e30
提出部分代码为方法,清晰化代码结构
binarywang Aug 13, 2016
ff2cd99
修复创建JS-API签名的漏洞
gaigeshen Aug 16, 2016
58f9570
Merge pull request #22 from gaigeshen/develop
binarywang Aug 16, 2016
87707fa
企业号全局配置存储添加Redis支持
gaigeshen Aug 17, 2016
27ad02d
Merge pull request #24 from gaigeshen/develop
kareanyi Aug 17, 2016
977161c
去掉多余容易引起误解的测试使用的接口方法oauth2buildAuthorizationUrl
binarywang Aug 18, 2016
184e6d7
WxMenuButton增加缺失的media_id字段
binarywang Aug 18, 2016
c8d21e3
格式化不规范的代码
binarywang Aug 19, 2016
30c914f
修复部分javadoc
binarywang Aug 19, 2016
a7846f9
重构部分代码,抽取重复代码为单独方法,并调整部分代码顺序
binarywang Aug 22, 2016
f2e251a
修复部分导致warning的代码
binarywang Aug 22, 2016
a70f937
格式化pom格式
binarywang Aug 23, 2016
bb0147b
转移统计分析相关接口为单独类,为以后完善补充统计分析接口做准备
binarywang Aug 23, 2016
8d72adc
fix javadoc error
binarywang Aug 23, 2016
d1a66b2
ignore bin folder created by eclipse ide.
xiaohulu Aug 24, 2016
00d7b85
Merge pull request #27 from xiaohulu/eclipse-ignore-bin
binarywang Aug 24, 2016
e8abad8
update javadoc
binarywang Aug 24, 2016
90b4b5c
更改toString方法
binarywang Aug 25, 2016
f38f31f
移动单元测试到类同名包下
binarywang Aug 25, 2016
f7454b6
重构,改名
binarywang Aug 25, 2016
f0cd7dd
重构,改名
binarywang Aug 25, 2016
14fb63d
添加图文分析数据接口
binarywang Aug 25, 2016
b5d9ce9
调整清理http连接的频率,避免过度日志输出
binarywang Aug 26, 2016
7bd75c9
重构DefaultApacheHttpClientBuilder
binarywang Aug 26, 2016
e016372
添加doctype,抑制warning
binarywang Aug 29, 2016
f262c74
添加输出日志代码,抑制warning
binarywang Aug 29, 2016
9c5b3c3
添加getter和setter方法
binarywang Aug 29, 2016
4c98a56
添加消息分析数据接口
binarywang Aug 29, 2016
a294bc4
修复部分可能造成resource leak的代码
binarywang Aug 29, 2016
f70a6a5
add gradle support
binarywang Aug 29, 2016
2db53ec
add gradle support,ignore something
binarywang Aug 29, 2016
c449e87
Merge branch 'master' into develop
binarywang Aug 30, 2016
ee158b6
添加Gradle的使用说明部分
binarywang Aug 30, 2016
4a994ea
调整部分段落位置
binarywang Aug 30, 2016
af9bfa2
添加接口分析数据接口
binarywang Aug 30, 2016
5525c4f
添加批量查询用户基本信息功能,没有测试,没有添加超过100验证
Aug 31, 2016
4047f6d
修改代码格式使用两个空格
Aug 31, 2016
1eadbc8
Merge pull request #29 from aimilin6688/develop
binarywang Aug 31, 2016
473feaf
fix javadoc
binarywang Aug 31, 2016
76e1da5
add missing @Override annotation
binarywang Aug 31, 2016
b991929
fix unqualified access
binarywang Aug 31, 2016
52b2a37
add serialVersionUID
binarywang Aug 31, 2016
05f809c
Remove redundant type arguments
binarywang Aug 31, 2016
dafbe07
remove unused imports
binarywang Aug 31, 2016
d17f113
fix potential resource leak
binarywang Aug 31, 2016
74737e2
fix javadoc
binarywang Aug 31, 2016
8bca9e7
版本号更新为2.1.0
binarywang Aug 31, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ test-output
hs_err_pid*

target
bin
.project
.classpath
.settings
Expand All @@ -21,3 +22,7 @@ sw-pom.xml
*.iml
test-config.xml
.idea
/.gradle/
/gradle/
*.bat
/gradlew
44 changes: 25 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,7 @@
#### 由于本次更新涉及接口调整比较大,主要是公众号的调整,企业号无过多调整,主要是为了解决主接口类过于庞大不方便管理的问题,将接口实现代码按模块进行拆分。因此版本号直接从1.X.X直接升级到2.0.0,所以如果习惯于1.X.X版本的同学不想做过多更改的话,请慎重考虑升级到最新版本。
---

#### 本项目主要存放在github上,地址为 :
* https://github.com/wechat-group/weixin-java-tools
* ===========但同时会在其他几个网站同步更新,地址分别是:
* https://bitbucket.org/binarywang/weixin-java-tools
* http://git.oschina.net/binary/weixin-java-tools
* https://git.coding.net/binarywang/weixin-java-tools.git

### 详细开发文档请看 [wiki](https://github.com/chanjarster/weixin-java-tools/wiki)。

## 目前可参考的Demo项目:
* https://github.com/wechat-group/weixin-java-tools-springmvc
* https://github.com/wechat-group/weixin-mp-demo
* ===========以下为备份仓库,会保持跟主仓库同步
* http://git.oschina.net/binary/weixin-mp-demo
* https://bitbucket.org/binarywang/weixin-mp-demo

===========
## 开发交流工具:
* QQ群:343954419 [![Join QQ Group](http://pub.idqqimg.com/wpa/images/group.png)](http://shang.qq.com/wpa/qunwpa?idkey=078f7a153d243853e24cf2b542e7a6ccbf2a592bc138080f84d11297f736ec46)
Expand All @@ -40,10 +25,9 @@
- [【企业号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-cp%22)


## Quick Start

* 如果要开发公众号(订阅号、服务号)应用,在你的maven项目中添加:
## Maven & Gradle

* 公众号(订阅号、服务号):
```xml
<dependency>
<groupId>com.github.binarywang</groupId>
Expand All @@ -52,8 +36,11 @@
</dependency>
```

* 如果要开发企业号应用,在你的maven项目中添加:
```groovy
compile 'com.github.binarywang:weixin-java-mp:2.0.0'
```

* 企业号:
```xml
<dependency>
<groupId>com.github.binarywang</groupId>
Expand All @@ -62,6 +49,25 @@
</dependency>
```

```groovy
compile 'com.github.binarywang:weixin-java-cp:2.0.0'
```

#### 本项目主要存放在github上,地址为 :
* https://github.com/wechat-group/weixin-java-tools
* ===========但同时会在其他几个网站同步更新,地址分别是:
* https://bitbucket.org/binarywang/weixin-java-tools
* http://git.oschina.net/binary/weixin-java-tools
* https://git.coding.net/binarywang/weixin-java-tools.git


## 目前可参考的Demo项目:
* https://github.com/wechat-group/weixin-java-tools-springmvc
* https://github.com/wechat-group/weixin-mp-demo
* ===========以下为备份仓库,会保持跟主仓库同步
* http://git.oschina.net/binary/weixin-mp-demo
* https://bitbucket.org/binarywang/weixin-mp-demo

## 关于代码贡献

* 非常欢迎和感谢对本项目发起Pull Request的同学,本项目可以采用两种方式接受代码贡献:
Expand Down
34 changes: 34 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
allprojects {
apply plugin: 'maven'

group = 'com.github.binarywang'
version = '2.1.0-SNAPSHOT'
}

subprojects {
apply plugin: 'java'
sourceCompatibility = 1.7
targetCompatibility = 1.7


repositories {
mavenLocal()

maven { url "http://maven.aliyun.com/nexus/content/groups/public" }
}


dependencies {
compile group: 'org.slf4j', name: 'slf4j-api', version:'1.7.10'
compile group: 'org.apache.httpcomponents', name: 'fluent-hc', version:'4.5'
compile group: 'org.apache.httpcomponents', name: 'httpmime', version:'4.5'
compile group: 'org.jodd', name: 'jodd-http', version:'3.6.7'
compile group: 'com.google.code.gson', name: 'gson', version:'2.7'
compile group: 'commons-codec', name: 'commons-codec', version:'1.10'
compile group: 'commons-io', name: 'commons-io', version:'2.5'
compile group: 'org.apache.commons', name: 'commons-lang3', version:'3.4'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version:'2.8.0'
compile group: 'redis.clients', name: 'jedis', version:'2.9.0'
testCompile group: 'ch.qos.logback', name: 'logback-classic', version:'1.1.2'
}
}
10 changes: 8 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-parent</artifactId>
<version>2.0.0</version>
<version>2.1.0</version>
<packaging>pom</packaging>
<name>WeiXin Java Tools - Parent</name>
<description>微信公众号、企业号上级POM</description>
Expand Down Expand Up @@ -50,6 +50,7 @@
<logback.version>1.1.2</logback.version>
<jodd-http.version>3.6.7</jodd-http.version>
<jackson.version>2.8.0</jackson.version>
<jedis.version>2.9.0</jedis.version>
<gson.version>2.7</gson.version>
<commons-lang3.version>3.4</commons-lang3.version>
<commons-io.version>2.5</commons-io.version>
Expand Down Expand Up @@ -110,8 +111,13 @@
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>${jedis.version}</version>
</dependency>
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
Expand Down
8 changes: 8 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
rootProject.name = 'weixin-java-parent'
include ':weixin-java-common'
include ':weixin-java-cp'
include ':weixin-java-mp'

project(':weixin-java-common').projectDir = "$rootDir/weixin-java-common" as File
project(':weixin-java-cp').projectDir = "$rootDir/weixin-java-cp" as File
project(':weixin-java-mp').projectDir = "$rootDir/weixin-java-mp" as File
12 changes: 12 additions & 0 deletions weixin-java-common/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

description = 'WeiXin Java Tools - Common'
dependencies {
compile group: 'com.thoughtworks.xstream', name: 'xstream', version:'1.4.7'
testCompile group: 'junit', name: 'junit', version:'4.11'
testCompile group: 'org.testng', name: 'testng', version:'6.8.7'
testCompile group: 'org.mockito', name: 'mockito-all', version:'1.9.5'
testCompile group: 'com.google.inject', name: 'guice', version:'3.0'
testCompile group: 'org.eclipse.jetty', name: 'jetty-server', version:'9.3.0.M0'
testCompile group: 'org.eclipse.jetty', name: 'jetty-servlet', version:'9.3.0.M0'
}
test.useTestNG()
2 changes: 1 addition & 1 deletion weixin-java-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-parent</artifactId>
<version>2.0.0</version>
<version>2.1.0</version>
</parent>

<artifactId>weixin-java-common</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class WxConsts {
public static final String XML_MSG_LINK = "link";
public static final String XML_MSG_EVENT = "event";
public static final String XML_TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service";

///////////////////////
// 主动发送消息(即客服消息)的消息类型
///////////////////////
Expand All @@ -33,7 +33,7 @@ public class WxConsts {
public static final String CUSTOM_MSG_TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service";
public static final String CUSTOM_MSG_SAFE_NO = "0";
public static final String CUSTOM_MSG_SAFE_YES = "1";

///////////////////////
// 群发消息的消息类型
///////////////////////
Expand All @@ -42,7 +42,7 @@ public class WxConsts {
public static final String MASS_MSG_VOICE = "voice";
public static final String MASS_MSG_IMAGE = "image";
public static final String MASS_MSG_VIDEO = "mpvideo";

///////////////////////
// 群发消息后微信端推送给服务器的反馈消息
///////////////////////
Expand All @@ -57,25 +57,11 @@ public class WxConsts {
public static final String MASS_ST_涉嫌版权 = "err(20013)";
public static final String MASS_ST_涉嫌互推_互相宣传 = "err(22000)";
public static final String MASS_ST_涉嫌其他 = "err(21000)";

/**
* 群发反馈消息代码所对应的文字描述
*/
public static final Map<String, String> MASS_ST_2_DESC = new HashMap<String, String>();
static {
MASS_ST_2_DESC.put(MASS_ST_SUCCESS, "发送成功");
MASS_ST_2_DESC.put(MASS_ST_FAIL, "发送失败");
MASS_ST_2_DESC.put(MASS_ST_涉嫌广告, "涉嫌广告");
MASS_ST_2_DESC.put(MASS_ST_涉嫌政治, "涉嫌政治");
MASS_ST_2_DESC.put(MASS_ST_涉嫌社会, "涉嫌社会");
MASS_ST_2_DESC.put(MASS_ST_涉嫌色情, "涉嫌色情");
MASS_ST_2_DESC.put(MASS_ST_涉嫌违法犯罪, "涉嫌违法犯罪");
MASS_ST_2_DESC.put(MASS_ST_涉嫌欺诈, "涉嫌欺诈");
MASS_ST_2_DESC.put(MASS_ST_涉嫌版权, "涉嫌版权");
MASS_ST_2_DESC.put(MASS_ST_涉嫌互推_互相宣传, "涉嫌互推_互相宣传");
MASS_ST_2_DESC.put(MASS_ST_涉嫌其他, "涉嫌其他");
}

///////////////////////
// 微信端推送过来的事件类型
///////////////////////
Expand Down Expand Up @@ -103,11 +89,9 @@ public class WxConsts {
public static final String EVT_USER_VIEW_CARD = "user_view_card";
public static final String EVT_USER_ENTER_SESSION_FROM_CARD = "user_enter_session_from_card";
public static final String EVT_CARD_SKU_REMIND = "card_sku_remind"; // 库存报警

public static final String EVT_KF_CREATE_SESSION = "kf_create_session"; // 客服接入会话
public static final String EVT_KF_CLOSE_SESSION = "kf_close_session"; // 客服关闭会话
public static final String EVT_KF_SWITCH_SESSION = "kf_switch_session"; // 客服转接会话

///////////////////////
// 上传多媒体文件的类型
///////////////////////
Expand All @@ -116,53 +100,89 @@ public class WxConsts {
public static final String MEDIA_VIDEO = "video";
public static final String MEDIA_THUMB = "thumb";
public static final String MEDIA_FILE = "file";

///////////////////////
// 文件类型
///////////////////////
public static final String FILE_JPG = "jpeg";
public static final String FILE_MP3 = "mp3";
public static final String FILE_AMR = "amr";
public static final String FILE_MP4 = "mp4";
/**
* 点击推事件
*/
public static final String BUTTON_CLICK = "click";


///////////////////////
// 自定义菜单的按钮类型
///////////////////////
/** 点击推事件 */
public static final String BUTTON_CLICK = "click";
/** 跳转URL */
/**
* 跳转URL
*/
public static final String BUTTON_VIEW = "view";
/** 扫码推事件 */
/**
* 扫码推事件
*/
public static final String BUTTON_SCANCODE_PUSH = "scancode_push";
/** 扫码推事件且弹出“消息接收中”提示框 */
/**
* 扫码推事件且弹出“消息接收中”提示框
*/
public static final String BUTTON_SCANCODE_WAITMSG = "scancode_waitmsg";
/** 弹出系统拍照发图 */
/**
* 弹出系统拍照发图
*/
public static final String BUTTON_PIC_SYSPHOTO = "pic_sysphoto";
/** 弹出拍照或者相册发图 */
/**
* 弹出拍照或者相册发图
*/
public static final String BUTTON_PIC_PHOTO_OR_ALBUM = "pic_photo_or_album";
/** 弹出微信相册发图器 */
/**
* 弹出微信相册发图器
*/
public static final String BUTTON_PIC_WEIXIN = "pic_weixin";
/** 弹出地理位置选择器 */
/**
* 弹出地理位置选择器
*/
public static final String BUTTON_LOCATION_SELECT = "location_select";
/** 下发消息(除文本消息) */
/**
* 下发消息(除文本消息)
*/
public static final String BUTTON_MEDIA_ID = "media_id";
/** 跳转图文消息URL */
/**
* 跳转图文消息URL
*/
public static final String BUTTON_VIEW_LIMITED = "view_limited";
/**
* 不弹出授权页面,直接跳转,只能获取用户openid
*/
public static final String OAUTH2_SCOPE_BASE = "snsapi_base";

///////////////////////
// oauth2网页授权的scope
///////////////////////
/** 不弹出授权页面,直接跳转,只能获取用户openid */
public static final String OAUTH2_SCOPE_BASE = "snsapi_base";
/** 弹出授权页面,可通过openid拿到昵称、性别、所在地。并且,即使在未关注的情况下,只要用户授权,也能获取其信息 */
/**
* 弹出授权页面,可通过openid拿到昵称、性别、所在地。并且,即使在未关注的情况下,只要用户授权,也能获取其信息
*/
public static final String OAUTH2_SCOPE_USER_INFO = "snsapi_userinfo";

///////////////////////
// 永久素材类型
///////////////////////
public static final String MATERIAL_NEWS = "news";
public static final String MATERIAL_VOICE = "voice";
public static final String MATERIAL_IMAGE = "image";
public static final String MATERIAL_VIDEO = "video";

static {
MASS_ST_2_DESC.put(MASS_ST_SUCCESS, "发送成功");
MASS_ST_2_DESC.put(MASS_ST_FAIL, "发送失败");
MASS_ST_2_DESC.put(MASS_ST_涉嫌广告, "涉嫌广告");
MASS_ST_2_DESC.put(MASS_ST_涉嫌政治, "涉嫌政治");
MASS_ST_2_DESC.put(MASS_ST_涉嫌社会, "涉嫌社会");
MASS_ST_2_DESC.put(MASS_ST_涉嫌色情, "涉嫌色情");
MASS_ST_2_DESC.put(MASS_ST_涉嫌违法犯罪, "涉嫌违法犯罪");
MASS_ST_2_DESC.put(MASS_ST_涉嫌欺诈, "涉嫌欺诈");
MASS_ST_2_DESC.put(MASS_ST_涉嫌版权, "涉嫌版权");
MASS_ST_2_DESC.put(MASS_ST_涉嫌互推_互相宣传, "涉嫌互推_互相宣传");
MASS_ST_2_DESC.put(MASS_ST_涉嫌其他, "涉嫌其他");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ public interface WxMessageDuplicateChecker {

/**
* <h2>公众号的排重方式</h2>
*
* <p>
* <p>普通消息:关于重试的消息排重,推荐使用msgid排重。<a href="http://mp.weixin.qq.com/wiki/10/79502792eef98d6e0c6e1739da387346.html">文档参考</a>。</p>
* <p>事件消息:关于重试的消息排重,推荐使用FromUserName + CreateTime 排重。<a href="http://mp.weixin.qq.com/wiki/2/5baf56ce4947d35003b86a9805634b1e.html">文档参考</a></p>
*
* <p>
* <h2>企业号的排重方式</h2>
*
* <p>
* 官方文档完全没有写,参照公众号的方式排重。
*
* <p>
* <p>或者可以采取更简单的方式,如果有MsgId就用MsgId排重,如果没有就用FromUserName+CreateTime排重</p>
*
* @param messageId messageId需要根据上面讲的方式构造
* @return 如果是重复消息,返回true,否则返回false
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public WxMessageInMemoryDuplicateChecker() {

/**
* WxMsgIdInMemoryDuplicateChecker构造函数
* @param timeToLive 一个消息ID在内存的过期时间:毫秒
*
* @param timeToLive 一个消息ID在内存的过期时间:毫秒
* @param clearPeriod 每隔多少周期检查消息ID是否过期:毫秒
*/
public WxMessageInMemoryDuplicateChecker(Long timeToLive, Long clearPeriod) {
Expand Down
Loading