forked from binarywang/weixin-java-mp-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
830689e
commit dee9994
Showing
29 changed files
with
617 additions
and
505 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,6 @@ | |
/.settings/ | ||
*.project | ||
*.classpath | ||
application.properties | ||
application.yml | ||
/.idea/ | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
language: java | ||
jdk: | ||
- oraclejdk8 | ||
|
||
script: "mvn clean package -Dmaven.test.skip=true" | ||
|
||
branches: | ||
only: | ||
- master | ||
|
||
notifications: | ||
email: | ||
- binaryw@qq.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
### 本Demo基于Spring Boot构建,实现微信公众号开发功能。 | ||
### 本项目为weixin-java-tools的Demo演示程序,更多Demo请查阅:https://github.com/Wechat-Group/weixin-java-tools | ||
|
||
[![Build Status](https://travis-ci.org/Wechat-Group/weixin-java-mp-demo-springboot.svg?branch=master)](https://travis-ci.org/Wechat-Group/weixin-java-mp-demo-springboot) | ||
----------------------- | ||
|
||
## 使用步骤: | ||
1. 配置:复制`/src/main/resources/application.yml.template` 生成application.yml文件,根据自己需要填写相关配置(需要注意的是:yml文件内的属性冒号后面的文字之前需要加空格,可参考已有配置,否则属性会设置不成功); | ||
1. 运行Java程序:`com.github.binarywang.demo.wechat.WxMpDemoApplication`; | ||
1. 打开shell或cmd,进入ngrok目录,运行 `ngrok -config ngrok.cfg -subdomain my-domain 8080` 如果运行失败,请更换my-domain为其它字符串,直至连接成功; | ||
1. 配置微信公众号中的接口地址:http://my-domain.tunnel.qydev.com/wechat/portal (注意my-domain要跟上面的一致,需要符合微信官方的要求); | ||
1. 根据自己需要修改各个handler的实现,加入自己的业务逻辑。 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
server_addr: "tunnel.qydev.com:4443" | ||
trust_host_root_certs: false | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 15 additions & 16 deletions
31
.../demo/wechat/WechatMpDemoApplication.java → ...wang/demo/wechat/WxMpDemoApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
package com.github.binarywang.demo.wechat; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
/** | ||
* | ||
* @author Binary Wang | ||
*/ | ||
@SpringBootApplication | ||
public class WechatMpDemoApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(WechatMpDemoApplication.class, args); | ||
} | ||
} | ||
package com.github.binarywang.demo.wechat; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
/** | ||
* @author Binary Wang(https://github.com/binarywang) | ||
*/ | ||
@SpringBootApplication | ||
public class WxMpDemoApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(WxMpDemoApplication.class, args); | ||
} | ||
} |
17 changes: 7 additions & 10 deletions
17
src/main/java/com/github/binarywang/demo/wechat/builder/AbstractBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,17 @@ | ||
package com.github.binarywang.demo.wechat.builder; | ||
|
||
import me.chanjar.weixin.mp.api.WxMpService; | ||
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; | ||
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import me.chanjar.weixin.mp.api.WxMpService; | ||
import me.chanjar.weixin.mp.bean.WxMpXmlMessage; | ||
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage; | ||
|
||
/** | ||
* | ||
* @author Binary Wang | ||
* | ||
* @author Binary Wang(https://github.com/binarywang) | ||
*/ | ||
public abstract class AbstractBuilder { | ||
protected final Logger logger = LoggerFactory.getLogger(getClass()); | ||
protected final Logger logger = LoggerFactory.getLogger(getClass()); | ||
|
||
public abstract WxMpXmlOutMessage build(String content, | ||
WxMpXmlMessage wxMessage, WxMpService service); | ||
public abstract WxMpXmlOutMessage build(String content, | ||
WxMpXmlMessage wxMessage, WxMpService service); | ||
} |
26 changes: 12 additions & 14 deletions
26
src/main/java/com/github/binarywang/demo/wechat/builder/ImageBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,24 @@ | ||
package com.github.binarywang.demo.wechat.builder; | ||
|
||
import me.chanjar.weixin.mp.api.WxMpService; | ||
import me.chanjar.weixin.mp.bean.WxMpXmlMessage; | ||
import me.chanjar.weixin.mp.bean.WxMpXmlOutImageMessage; | ||
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage; | ||
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; | ||
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutImageMessage; | ||
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; | ||
|
||
/** | ||
* | ||
* @author Binary Wang | ||
* | ||
* @author Binary Wang(https://github.com/binarywang) | ||
*/ | ||
public class ImageBuilder extends AbstractBuilder { | ||
|
||
@Override | ||
public WxMpXmlOutMessage build(String content, WxMpXmlMessage wxMessage, | ||
WxMpService service) { | ||
@Override | ||
public WxMpXmlOutMessage build(String content, WxMpXmlMessage wxMessage, | ||
WxMpService service) { | ||
|
||
WxMpXmlOutImageMessage m = WxMpXmlOutMessage.IMAGE().mediaId(content) | ||
.fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) | ||
.build(); | ||
WxMpXmlOutImageMessage m = WxMpXmlOutMessage.IMAGE().mediaId(content) | ||
.fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) | ||
.build(); | ||
|
||
return m; | ||
} | ||
return m; | ||
} | ||
|
||
} |
26 changes: 12 additions & 14 deletions
26
src/main/java/com/github/binarywang/demo/wechat/builder/TextBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,22 @@ | ||
package com.github.binarywang.demo.wechat.builder; | ||
|
||
import me.chanjar.weixin.mp.api.WxMpService; | ||
import me.chanjar.weixin.mp.bean.WxMpXmlMessage; | ||
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage; | ||
import me.chanjar.weixin.mp.bean.WxMpXmlOutTextMessage; | ||
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; | ||
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; | ||
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutTextMessage; | ||
|
||
/** | ||
* | ||
* @author Binary Wang | ||
* | ||
* @author Binary Wang(https://github.com/binarywang) | ||
*/ | ||
public class TextBuilder extends AbstractBuilder { | ||
|
||
@Override | ||
public WxMpXmlOutMessage build(String content, WxMpXmlMessage wxMessage, | ||
WxMpService service) { | ||
WxMpXmlOutTextMessage m = WxMpXmlOutMessage.TEXT().content(content) | ||
.fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) | ||
.build(); | ||
return m; | ||
} | ||
@Override | ||
public WxMpXmlOutMessage build(String content, WxMpXmlMessage wxMessage, | ||
WxMpService service) { | ||
WxMpXmlOutTextMessage m = WxMpXmlOutMessage.TEXT().content(content) | ||
.fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) | ||
.build(); | ||
return m; | ||
} | ||
|
||
} |
Oops, something went wrong.