mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-06-28 13:16:19 +08:00
new README
This commit is contained in:
parent
a8f5d07ff3
commit
f76f0e6773
34
README.md
Normal file
34
README.md
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
weixin-java-cp
|
||||||
|
===========
|
||||||
|
|
||||||
|
微信公众号、企业号Java SDK。
|
||||||
|
|
||||||
|
从``1.0.3``开始,本项目拆分成3个部分:
|
||||||
|
|
||||||
|
1. weixin-java-common,公共lib
|
||||||
|
2. weixin-java-cp,企业号SDK
|
||||||
|
3. weixin-java-mp,公众号(订阅号、服务号)SDK
|
||||||
|
|
||||||
|
详细文档请看 [wiki](https://github.com/chanjarster/weixin-java-tools/wiki)
|
||||||
|
|
||||||
|
# Quick Start
|
||||||
|
|
||||||
|
如果要开发公众号(订阅号、服务号)应用,在你的maven项目中添加:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.chanjar</groupId>
|
||||||
|
<artifactId>weixin-java-mp</artifactId>
|
||||||
|
<version>1.0.3</version>
|
||||||
|
</dependency>
|
||||||
|
```
|
||||||
|
|
||||||
|
如果要开发企业号应用,在你的maven项目中添加:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.chanjar</groupId>
|
||||||
|
<artifactId>weixin-java-cp</artifactId>
|
||||||
|
<version>1.0.3</version>
|
||||||
|
</dependency>
|
||||||
|
```
|
@ -1,46 +0,0 @@
|
|||||||
weixin-java-cp
|
|
||||||
===========
|
|
||||||
|
|
||||||
微信企业号Java SDK开发工具集,本项目主要分为两大块:微信消息路由器、微信Java API
|
|
||||||
|
|
||||||
详细文档请看 [wiki](https://github.com/chanjarster/weixin-java-tools/wiki)
|
|
||||||
|
|
||||||
# Quickstart
|
|
||||||
|
|
||||||
在你的maven项目中添加:
|
|
||||||
```xml
|
|
||||||
<dependency>
|
|
||||||
<groupId>me.chanjar</groupId>
|
|
||||||
<artifactId>weixin-java-cp-tools</artifactId>
|
|
||||||
<version>1.0.3</version>
|
|
||||||
</dependency>
|
|
||||||
```
|
|
||||||
|
|
||||||
如果要使用``*-SNAPSHOT``版,则需要在你的``pom.xml``中添加这段:
|
|
||||||
|
|
||||||
```xml
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<snapshots />
|
|
||||||
<id>sonatype snapshots</id>
|
|
||||||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Hello World
|
|
||||||
```java
|
|
||||||
WxCpInMemoryConfigStorage config = new WxCpInMemoryConfigStorage();
|
|
||||||
config.getCorpId(...); // 设置微信企业号的appid
|
|
||||||
config.getCorpSecret(...); // 设置微信企业号的app corpSecret
|
|
||||||
config.setAgentId(...); // 设置微信企业号应用ID
|
|
||||||
config.setToken(...); // 设置微信企业号应用的token
|
|
||||||
config.setAesKey(...); // 设置微信企业号应用的EncodingAESKey
|
|
||||||
|
|
||||||
WxCpServiceImpl wxCpService = new WxCpServiceImpl();
|
|
||||||
wxCpService.setWxCpConfigStorage(config);
|
|
||||||
|
|
||||||
String userId = ...;
|
|
||||||
WxCpMessage message = WxCpMessage.TEXT().agentId(...).toUser(userId).content("Hello World").build();
|
|
||||||
wxService.messageSend(message);
|
|
||||||
```
|
|
@ -1,57 +0,0 @@
|
|||||||
weixin-java-tools
|
|
||||||
===========
|
|
||||||
|
|
||||||
微信java开发工具集,本项目主要分为两大块:微信消息路由器、微信Java API
|
|
||||||
|
|
||||||
特性列表:
|
|
||||||
|
|
||||||
1. 不基于Servlet、和其他MVC框架,仅作为工具使用,提供更多的灵活性
|
|
||||||
2. 详尽的单元测试代码,可以拿来当example用
|
|
||||||
3. 详尽的javadoc
|
|
||||||
4. access token过期自动刷新的功能
|
|
||||||
5. 微信服务端繁忙自动重试的功能
|
|
||||||
6. 提供微信错误信息的异常处理机制
|
|
||||||
|
|
||||||
|
|
||||||
详细文档请看 [wiki](https://github.com/chanjarster/weixin-java-tools/wiki)
|
|
||||||
|
|
||||||
# Quickstart
|
|
||||||
|
|
||||||
在你的maven项目中添加:
|
|
||||||
```xml
|
|
||||||
<dependency>
|
|
||||||
<groupId>me.chanjar</groupId>
|
|
||||||
<artifactId>weixin-java-tools</artifactId>
|
|
||||||
<version>1.0.2</version>
|
|
||||||
</dependency>
|
|
||||||
```
|
|
||||||
|
|
||||||
如果要使用``*-SNAPSHOT``版,则需要在你的``pom.xml``中添加这段:
|
|
||||||
|
|
||||||
```xml
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<snapshots />
|
|
||||||
<id>sonatype snapshots</id>
|
|
||||||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Hello World
|
|
||||||
```java
|
|
||||||
WxInMemoryConfigStorage config = new WxInMemoryConfigStorage();
|
|
||||||
config.setAppId(...); // 设置微信公众号的appid
|
|
||||||
config.setSecret(...); // 设置微信公众号的app secret
|
|
||||||
config.setToken(...); // 设置微信公众号的token
|
|
||||||
config.setAesKey(...); // 设置微信公众号的EncodingAESKey
|
|
||||||
|
|
||||||
WxServiceImpl wxService = new WxServiceImpl();
|
|
||||||
wxService.setWxConfigStorage(config);
|
|
||||||
|
|
||||||
// 用户的openid在下面地址获得
|
|
||||||
// https://mp.weixin.qq.com/debug/cgi-bin/apiinfo?t=index&type=用户管理&form=获取关注者列表接口%20/user/get
|
|
||||||
String openId = ...;
|
|
||||||
WxCustomMessage message = WxCustomMessage.TEXT().toUser(openId).content("Hello World").build();
|
|
||||||
wxService.customMessageSend(message);
|
|
||||||
```
|
|
Loading…
Reference in New Issue
Block a user