Skip to content

Commit b09c5ae

Browse files
authored
Merge pull request #1 from wechat-group/develop
update from origin
2 parents 5885ce8 + 72d6aad commit b09c5ae

File tree

200 files changed

+4013
-3941
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+4013
-3941
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ test-config.xml
2626
/gradle/
2727
*.bat
2828
/gradlew
29+
**/build/
2930

3031
# OSX
3132
# Icon must end with two \r

README.md

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
1-
# Weixin Java Tools 微信公众号/企业号开发Java SDK
2-
## [![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badge/) ![Maven Central](https://img.shields.io/maven-central/v/com.github.binarywang/weixin-java-parent.svg) [![Build Status](https://travis-ci.org/wechat-group/weixin-java-tools.svg?branch=develop)](https://travis-ci.org/wechat-group/weixin-java-tools)
3-
1+
Weixin Java Tools 微信公众号/企业号开发Java SDK
2+
=====================================
3+
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.binarywang/weixin-java-parent/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.binarywang/weixin-java-parent)
4+
[![Build Status](https://travis-ci.org/wechat-group/weixin-java-tools.svg?branch=develop)](https://travis-ci.org/wechat-group/weixin-java-tools)
45

56
### 注意:
67
1. ***本项目Fork自chanjarster/weixin-java-tools,但由于原项目已停止维护,故单独维护和发布,且发布到maven上的groupId也会不同,详细信息见下文。***
78
1. ***自2.0.0版本以来,公众号的接口调整比较大,主要是为了解决主接口类过于庞大不方便管理的问题,将接口实现代码按模块进行拆分。***
89
1. 本SDK要求的最低JDK版本是7,为满足少量还在使用JDK6的用户的需求,特意抽出独立的代码分支项目,请参考 https://github.com/binarywang/weixin-java-tools-for-jdk6 ,其他更早的JDK版本则需要自己改造实现;
9-
1. 最新更新:2016-09-30 发布2.2.0正式版!
10+
1. 最新更新:2016-10-31 发布2.3.0正式版!
1011

1112
===========
1213

13-
## 开发交流方式:
14-
1. ***QQ群入群须知:为保证入群成员质量,请申请入群前,先Star本项目,然后在申请入群时,输入您的Github帐号ID,以便管理员核对,ID即你的github主页地址https://github.com/XXXX 中最后的部分XXXX的内容,或者在github网页右上角点击头像后查看Signed in as后方内容。***
14+
## 开发交流方式及注意事项:
15+
1. QQ群:343954419(推荐点击按钮入群: [![Join QQ Group](http://pub.idqqimg.com/wpa/images/group.png)](http://shang.qq.com/wpa/qunwpa?idkey=731dc3e7ea31ebe25376cc1a791445468612c63fd0e9e05399b088ec81fd9e15)[![Join QQ Group](http://pub.idqqimg.com/wpa/images/group.png)](http://jq.qq.com/?_wv=1027&k=40lRskK),如果无反应,可以自行搜索群号进行添加 )
16+
1. 由于群容量有限即将爆满,现开启付费入群模式,并不定期清理长时间不活跃人士;
17+
1. 微信群: 因微信群已达到100人限制,故如有想加入微信群的,请入QQ群后联系管理员,提供微信号以便邀请加入;
1518
1. 新手提问前,请先阅读此文章:http://t.cn/RV93MRB
1619
1. 寻求帮助时需贴代码或大长串异常信息的,请利用http://paste.ubuntu.com
17-
1. QQ群:343954419 [![Join QQ Group](http://pub.idqqimg.com/wpa/images/group.png)](http://shang.qq.com/wpa/qunwpa?idkey=078f7a153d243853e24cf2b542e7a6ccbf2a592bc138080f84d11297f736ec46)
18-
1. 微信群: 因微信群已达到100人限制,故如有想加入微信群的,请入QQ群后联系管理员,提供微信号以便邀请加入;
1920
1. 有功能需求或由于微信官方接口调整导致的代码问题,可以直接提出issue,便于讨论追踪问题;
20-
1. 详细开发文档请看 [Wiki](https://github.com/wechat-group/weixin-java-tools/wiki)
21+
1. 详细开发文档请看 [Wiki](https://github.com/wechat-group/weixin-java-tools/wiki),部分文档可能未能及时更新,如有发现,可以及时上报或者自行修改。
22+
1. 微信公众号官方文档入口地址:http://mp.weixin.qq.com/wiki (注意,从网上搜到的文档有的虽然地址前面跟这个一样,但明显左侧菜单不一致,是旧的文档,注意不要看错文档)。
23+
1. 各个模块的Javadoc可以在线查看:[weixin-java-mp](https://binarywang.github.io/weixin-java-mp-javadoc/)[weixin-java-common](https://binarywang.github.io/weixin-java-common-javadoc/)[weixin-java-cp](https://binarywang.github.io/weixin-java-cp-javadoc/)
2124

2225
===========
2326

2427
## 版本说明
2528
1. 本项目定为每月发布一次正式版,版本号格式为X.X.0(如2.1.0,2.2.0等),月初或月底发布新版本,遇到重大问题需修复会及时提交新版本,欢迎大家随时提交Pull Request;
2629
1. BUG修复和新特性一般会先发布成小版本作为临时版本(如2.0.1,2.0.2等,即尾号不为0,以区别于正式版);
27-
1. 目前最新版本号为 ![Maven Central](https://img.shields.io/maven-central/v/com.github.binarywang/weixin-java-parent.svg) ,也可以通过访问链接 [【公众号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-mp%22)[【企业号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-cp%22)
30+
1. 目前最新版本号为 [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.binarywang/weixin-java-parent/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.binarywang/weixin-java-parent) ,也可以通过访问链接 [【公众号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-mp%22)[【企业号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-cp%22)
2831
分别查看所有最新的版本。
2932

3033
## Maven & Gradle
@@ -36,12 +39,12 @@ maven:
3639
<dependency>
3740
<groupId>com.github.binarywang</groupId>
3841
<artifactId>weixin-java-mp</artifactId>
39-
<version>2.2.0</version>
42+
<version>2.3.0</version>
4043
</dependency>
4144
```
4245
gradle:
4346
```groovy
44-
compile 'com.github.binarywang:weixin-java-mp:2.2.0'
47+
compile 'com.github.binarywang:weixin-java-mp:2.3.0'
4548
```
4649

4750
* 企业号:
@@ -51,12 +54,12 @@ maven:
5154
<dependency>
5255
<groupId>com.github.binarywang</groupId>
5356
<artifactId>weixin-java-cp</artifactId>
54-
<version>2.2.0</version>
57+
<version>2.3.0</version>
5558
</dependency>
5659
```
5760
gradle:
5861
```groovy
59-
compile 'com.github.binarywang:weixin-java-cp:2.2.0'
62+
compile 'com.github.binarywang:weixin-java-cp:2.3.0'
6063
```
6164

6265
===========
@@ -69,15 +72,42 @@ compile 'com.github.binarywang:weixin-java-cp:2.2.0'
6972
* https://git.coding.net/binarywang/weixin-java-tools.git
7073

7174
===========
72-
## 目前可参考的Demo项目有两个(目前都是公众号的,风格不同,欢迎提供更多的demo供新手参考):
73-
1. https://github.com/wechat-group/weixin-mp-demo
75+
## 可参考的Demo项目
76+
#### 目前都是公众号的,风格不同,欢迎提供更多的demo供新手参考:
77+
1. https://github.com/wechat-group/weixin-mp-demo
78+
1. https://github.com/wechat-group/weixin-mp-multi-demo (支持多公众号)
7479
1. https://github.com/wechat-group/weixin-java-tools-springmvc
80+
1. https://github.com/wechat-group/weixin-mp-demo-springboot
81+
7582

7683
===========
7784
## 关于代码贡献
7885
1. 非常欢迎和感谢对本项目发起Pull Request的同学,本项目代码风格为使用2个空格代表一个Tab,因此在提交代码时请注意一下,否则很容易在IDE格式化代码后与原代码产生大量diff,这样会给其他人阅读代码带来极大的困扰。
7986
1. 为了便于设置,本项目引入editorconfig插件,请使用eclipse的同学在贡献代码前安装相关插件,IntelliJ IDEA则自带支持,无需额外安装插件。
8087
1. 本项目可以采用两种方式接受代码贡献:
88+
* 第一种就是基于[Git Flow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow)开发流程,因此在发起Pull Request的时候请选择develop分支,详细步骤参考后文。
89+
* 另外一种贡献代码的方式就是加入SDK Developers开发组,前提是对自己的代码足够自信就可以申请加入,加入之后可以随时直接提交代码,但要注意对所做的修改或新增的代码进行单元测试,保证提交代码没有明显问题,具体加入方式,请咨询QQ群管理员[![点击这里给我发消息](http://wpa.qq.com/pa?p=2:1211415707:51)](http://wpa.qq.com/msgrd?v=3&uin=1211415707&site=qq&menu=yes)
8190

82-
1. 第一种就是基于[Git Flow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow)开发流程,因此在发起Pull Request的时候请选择develop分支。
83-
1. 另外一种贡献代码的方式就是加入SDK Developers开发组,前提是对自己的代码足够自信就可以申请加入,加入之后可以随时直接提交代码,但要注意对所做的修改或新增的代码进行单元测试,保证提交代码没有明显问题,具体加入方式,请咨询管理员。
91+
## PR方式贡献代码步骤
92+
* 在 GitHub 上 `fork` 到自己的仓库,如 `my_user/weixin-java-tools`,然后 `clone` 到本地,并设置用户信息。
93+
```
94+
$ git clone [email protected]:my_user/weixin-java-tools.git
95+
$ cd weixin-java-tools
96+
$ git config user.name "yourname"
97+
$ git config user.email "your email"
98+
```
99+
* 修改代码后提交,并推送到自己的仓库。
100+
```
101+
$ #do some change on the content
102+
$ git commit -am "Fix issue #1: change something"
103+
$ git push
104+
```
105+
* 在 GitHub 网站上提交 Pull Request。
106+
* 定期使用项目仓库内容更新自己仓库内容。
107+
```
108+
$ git remote add upstream https://github.com/wechat-group/weixin-java-tools
109+
$ git fetch upstream
110+
$ git checkout develop
111+
$ git rebase upstream/develop
112+
$ git push -f origin develop
113+
```

build.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ allprojects {
22
apply plugin: 'maven'
33

44
group = 'com.github.binarywang'
5-
version = '2.2.0'
5+
version = '2.4.0-SNAPSHOT'
66
}
77

88
subprojects {
@@ -21,10 +21,9 @@ subprojects {
2121
dependencies {
2222
compile group: 'org.slf4j', name: 'slf4j-api', version:'1.7.10'
2323
compile group: 'org.apache.httpcomponents', name: 'httpmime', version:'4.5'
24-
compile group: 'org.jodd', name: 'jodd-http', version:'3.6.7'
24+
compile group: 'org.apache.httpcomponents', name: 'httpclient', version:'4.5'
2525
compile group: 'com.google.code.gson', name: 'gson', version:'2.7'
2626
compile group: 'com.google.guava', name: 'guava', version:'19.0'
27-
compile group: 'org.jooq', name: 'joor', version:'0.9.6'
2827
compile group: 'commons-codec', name: 'commons-codec', version:'1.10'
2928
compile group: 'commons-io', name: 'commons-io', version:'2.5'
3029
compile group: 'org.apache.commons', name: 'commons-lang3', version:'3.4'

pom.xml

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>com.github.binarywang</groupId>
77
<artifactId>weixin-java-parent</artifactId>
8-
<version>2.3.0-SNAPSHOT</version>
8+
<version>2.4.0-SNAPSHOT</version>
99
<packaging>pom</packaging>
1010
<name>WeiXin Java Tools - Parent</name>
1111
<description>微信公众号、企业号上级POM</description>
12-
<url>https://github.com/binarywang/weixin-java-tools</url>
12+
<url>https://github.com/wechat-group/weixin-java-tools</url>
1313

1414
<licenses>
1515
<license>
@@ -22,17 +22,44 @@
2222
<developer>
2323
<name>Daniel Qian</name>
2424
<email>[email protected]</email>
25+
<url>https://github.com/chanjarster</url>
2526
</developer>
2627
<developer>
2728
<name>Binary Wang</name>
2829
<email>[email protected]</email>
30+
<url>https://github.com/binarywang</url>
31+
</developer>
32+
<developer>
33+
<name>gaigeshen</name>
34+
<email>[email protected]</email>
35+
<url>https://github.com/gaigeshen</url>
36+
</developer>
37+
<developer>
38+
<name>Liu Mingbo</name>
39+
<email>[email protected]</email>
40+
<url>https://github.com/FirenzesEagle</url>
41+
</developer>
42+
<developer>
43+
<name>kakotor</name>
44+
<email>[email protected]</email>
45+
<url>https://github.com/kakotor</url>
46+
</developer>
47+
<developer>
48+
<name>xiong</name>
49+
<email>[email protected]</email>
50+
<url>https://github.com/ZhaoxiongTan</url>
51+
</developer>
52+
<developer>
53+
<name>LiuJunGuang</name>
54+
<email>[email protected]</email>
55+
<url>https://github.com/aimilin6688</url>
2956
</developer>
3057
</developers>
3158

3259
<scm>
33-
<connection>scm:git:https://github.com/binarywang/weixin-java-tools.git</connection>
34-
<developerConnection>scm:git:[email protected]:binarywang/weixin-java-tools.git</developerConnection>
35-
<url>https://github.com/binarywang/weixin-java-tools</url>
60+
<connection>scm:git:https://github.com/wechat-group/weixin-java-tools.git</connection>
61+
<developerConnection>scm:git:[email protected]:wechat-group/weixin-java-tools.git</developerConnection>
62+
<url>https://github.com/wechat-group/weixin-java-tools</url>
3663
</scm>
3764

3865
<modules>
@@ -43,22 +70,22 @@
4370
</modules>
4471

4572
<properties>
73+
<maven.compiler.source>1.7</maven.compiler.source>
74+
<maven.compiler.target>1.7</maven.compiler.target>
75+
4676
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4777
<downloadJavadocs>true</downloadJavadocs>
4878
<downloadSources>true</downloadSources>
4979
<httpclient.version>4.5</httpclient.version>
5080
<slf4j.version>1.7.10</slf4j.version>
5181
<logback.version>1.1.2</logback.version>
52-
<jodd-http.version>3.6.7</jodd-http.version>
5382
<jedis.version>2.9.0</jedis.version>
5483
<gson.version>2.7</gson.version>
5584
<guava.version>19.0</guava.version>
56-
<joor.version>0.9.6</joor.version>
57-
<commons-lang3.version>3.4</commons-lang3.version>
85+
<commons-lang3.version>3.5</commons-lang3.version>
5886
<commons-io.version>2.5</commons-io.version>
5987
<commons-codec.version>1.10</commons-codec.version>
60-
<jetty.version>9.3.0.M0</jetty.version>
61-
<jetty-new.version>9.3.10.v20160621</jetty-new.version>
88+
<jetty.version>9.3.0.RC0</jetty.version>
6289
</properties>
6390

6491
<dependencies>
@@ -75,13 +102,13 @@
75102
</dependency>
76103
<dependency>
77104
<groupId>org.apache.httpcomponents</groupId>
78-
<artifactId>httpmime</artifactId>
105+
<artifactId>httpclient</artifactId>
79106
<version>${httpclient.version}</version>
80107
</dependency>
81108
<dependency>
82-
<groupId>org.jodd</groupId>
83-
<artifactId>jodd-http</artifactId>
84-
<version>${jodd-http.version}</version>
109+
<groupId>org.apache.httpcomponents</groupId>
110+
<artifactId>httpmime</artifactId>
111+
<version>${httpclient.version}</version>
85112
</dependency>
86113
<dependency>
87114
<groupId>com.google.code.gson</groupId>
@@ -113,10 +140,6 @@
113140
<groupId>com.google.guava</groupId>
114141
<artifactId>guava</artifactId>
115142
</dependency>
116-
<dependency>
117-
<groupId>org.jooq</groupId>
118-
<artifactId>joor</artifactId>
119-
</dependency>
120143
</dependencies>
121144

122145
<dependencyManagement>
@@ -162,11 +185,6 @@
162185
<artifactId>guava</artifactId>
163186
<version>${guava.version}</version>
164187
</dependency>
165-
<dependency>
166-
<groupId>org.jooq</groupId>
167-
<artifactId>joor</artifactId>
168-
<version>${joor.version}</version>
169-
</dependency>
170188
</dependencies>
171189
</dependencyManagement>
172190

@@ -286,10 +304,8 @@
286304
<plugin>
287305
<groupId>org.apache.maven.plugins</groupId>
288306
<artifactId>maven-compiler-plugin</artifactId>
289-
<version>2.3.2</version>
307+
<version>3.6.0</version>
290308
<configuration>
291-
<source>1.7</source>
292-
<target>1.7</target>
293309
<encoding>UTF-8</encoding>
294310
</configuration>
295311
</plugin>

weixin-java-common/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies {
66
testCompile group: 'org.testng', name: 'testng', version:'6.8.7'
77
testCompile group: 'org.mockito', name: 'mockito-all', version:'1.9.5'
88
testCompile group: 'com.google.inject', name: 'guice', version:'3.0'
9-
testCompile group: 'org.eclipse.jetty', name: 'jetty-server', version:'9.3.0.M0'
10-
testCompile group: 'org.eclipse.jetty', name: 'jetty-servlet', version:'9.3.0.M0'
9+
testCompile group: 'org.eclipse.jetty', name: 'jetty-server', version:'9.3.0.RC0'
10+
testCompile group: 'org.eclipse.jetty', name: 'jetty-servlet', version:'9.3.0.RC0'
1111
}
1212
test.useTestNG()

weixin-java-common/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.github.binarywang</groupId>
88
<artifactId>weixin-java-parent</artifactId>
9-
<version>2.3.0-SNAPSHOT</version>
9+
<version>2.4.0-SNAPSHOT</version>
1010
</parent>
1111

1212
<artifactId>weixin-java-common</artifactId>

weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ public class WxConsts {
2323
///////////////////////
2424
// 主动发送消息(即客服消息)的消息类型
2525
///////////////////////
26-
public static final String CUSTOM_MSG_TEXT = "text";
27-
public static final String CUSTOM_MSG_IMAGE = "image";
28-
public static final String CUSTOM_MSG_VOICE = "voice";
29-
public static final String CUSTOM_MSG_VIDEO = "video";
30-
public static final String CUSTOM_MSG_MUSIC = "music";
31-
public static final String CUSTOM_MSG_NEWS = "news";
32-
public static final String CUSTOM_MSG_FILE = "file";
33-
public static final String CUSTOM_MSG_WXCARD = "wxcard";
26+
public static final String CUSTOM_MSG_TEXT = "text";//文本消息
27+
public static final String CUSTOM_MSG_IMAGE = "image";//图片消息
28+
public static final String CUSTOM_MSG_VOICE = "voice";//语音消息
29+
public static final String CUSTOM_MSG_VIDEO = "video";//视频消息
30+
public static final String CUSTOM_MSG_MUSIC = "music";//音乐消息
31+
public static final String CUSTOM_MSG_NEWS = "news";//图文消息(点击跳转到外链)
32+
public static final String CUSTOM_MSG_MPNEWS = "mpnews";//图文消息(点击跳转到图文消息页面)
33+
public static final String CUSTOM_MSG_FILE = "file";//发送文件(CP专用)
34+
public static final String CUSTOM_MSG_WXCARD = "wxcard";//卡券消息
3435
public static final String CUSTOM_MSG_TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service";
3536
public static final String CUSTOM_MSG_SAFE_NO = "0";
3637
public static final String CUSTOM_MSG_SAFE_YES = "1";
@@ -193,7 +194,7 @@ public class WxConsts {
193194
* 弹出授权页面,可通过openid拿到昵称、性别、所在地。并且,即使在未关注的情况下,只要用户授权,也能获取其信息
194195
*/
195196
public static final String OAUTH2_SCOPE_USER_INFO = "snsapi_userinfo";
196-
197+
197198
/**
198199
* 网页应用登录授权作用域 snsapi_login
199200
*/

weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxCardApiSignature.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package me.chanjar.weixin.common.bean;
22

3-
import java.io.Serializable;
3+
import me.chanjar.weixin.common.util.ToStringUtils;
44

5-
import org.apache.commons.lang3.builder.ToStringBuilder;
6-
import org.apache.commons.lang3.builder.ToStringStyle;
5+
import java.io.Serializable;
76

87
/**
98
* 卡券Api签名
@@ -35,7 +34,7 @@ public class WxCardApiSignature implements Serializable {
3534

3635
@Override
3736
public String toString() {
38-
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
37+
return ToStringUtils.toSimpleString(this);
3938
}
4039

4140
public String getAppId() {

weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuButton.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package me.chanjar.weixin.common.bean.menu;
22

3+
import me.chanjar.weixin.common.util.ToStringUtils;
4+
35
import java.util.ArrayList;
46
import java.util.List;
57

6-
import org.apache.commons.lang3.builder.ToStringBuilder;
7-
import org.apache.commons.lang3.builder.ToStringStyle;
8-
98
public class WxMenuButton {
109

1110
private String type;
@@ -18,10 +17,9 @@ public class WxMenuButton {
1817

1918
@Override
2019
public String toString() {
21-
return ToStringBuilder.reflectionToString(this,
22-
ToStringStyle.MULTI_LINE_STYLE);
20+
return ToStringUtils.toSimpleString(this);
2321
}
24-
22+
2523
public String getType() {
2624
return this.type;
2725
}
@@ -69,4 +67,4 @@ public String getMediaId() {
6967
public void setMediaId(String mediaId) {
7068
this.mediaId = mediaId;
7169
}
72-
}
70+
}

0 commit comments

Comments
 (0)