dev --- 3.8.0.A版本, openProject引用 ; formao-live --- 3.7.0.B 版本, formallProject引用
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

README.md 1.6 KiB

10 anni fa
10 anni fa
10 anni fa
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. weixin-java-tools
  2. ===========
  3. 微信java开发工具集,本项目主要分为两大块:微信消息路由器、微信Java API
  4. 特性列表:
  5. 1. 不基于Servlet、和其他MVC框架,仅作为工具使用,提供更多的灵活性
  6. 2. 详尽的单元测试代码,可以拿来当example用
  7. 3. 详尽的javadoc
  8. 4. access token过期自动刷新的功能
  9. 5. 微信服务端繁忙自动重试的功能
  10. 6. 提供微信错误信息的异常处理机制
  11. 详细文档请看 [wiki](https://github.com/chanjarster/weixin-java-tools/wiki)
  12. # Quickstart
  13. 在你的maven项目中添加:
  14. ```xml
  15. <dependency>
  16. <groupId>me.chanjar</groupId>
  17. <artifactId>weixin-java-tools</artifactId>
  18. <version>1.0.2</version>
  19. </dependency>
  20. ```
  21. 如果要使用``*-SNAPSHOT``版,则需要在你的``pom.xml``中添加这段:
  22. ```xml
  23. <repositories>
  24. <repository>
  25. <snapshots />
  26. <id>sonatype snapshots</id>
  27. <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
  28. </repository>
  29. </repositories>
  30. ```
  31. ## Hello World
  32. ```java
  33. WxConfigStorage config = new WxInMemoryConfigStorage();
  34. config.setAppId(...); // 设置微信公众号的appid
  35. config.setSecret(...); // 设置微信公众号的app secret
  36. config.setToken(...); // 设置微信公众号的token
  37. WxServiceImpl wxService = new WxServiceImpl();
  38. wxService.setWxConfigStorage(config);
  39. // 用户的openid在下面地址获得
  40. // https://mp.weixin.qq.com/debug/cgi-bin/apiinfo?t=index&type=用户管理&form=获取关注者列表接口%20/user/get
  41. String openId = ...;
  42. WxCustomMessage message = WxCustomMessage.TEXT().toUser(openId).content("Hello World").build();
  43. wxService.customMessageSend(message);
  44. ```