diff --git a/README.md b/README.md index 6a05a94f..b6ee7b6d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## WxJava - 微信开发 Java SDK(开发工具包) [![LICENSE](https://img.shields.io/badge/License-Anti%20996-blue.svg)](https://github.com/996icu/996.ICU/blob/master/LICENSE) [![Badge](https://img.shields.io/badge/Link-996.icu-red.svg)](https://996.icu/#/zh_CN) [![Badge](https://img.shields.io/badge/Link-京东内购福利-red.svg)](https://mp.weixin.qq.com/s/dfwatgMgARaBjh421Todyg) +## WxJava - 微信开发 Java SDK(开发工具包) [![LICENSE](https://img.shields.io/badge/License-Anti%20996-blue.svg)](https://github.com/996icu/996.ICU/blob/master/LICENSE) [![Badge](https://img.shields.io/badge/Link-996.icu-red.svg)](https://996.icu/#/zh_CN) [![Badge](https://img.shields.io/badge/Link-专属福利-red.svg)](https://mp.weixin.qq.com/s/dfwatgMgARaBjh421Todyg) [![码云Gitee](https://gitee.com/binary/weixin-java-tools/badge/star.svg?theme=blue)](https://gitee.com/binary/weixin-java-tools) [![Github](http://github-svg-buttons.herokuapp.com/star.svg?user=Wechat-Group&repo=WxJava&style=flat&background=1081C1)](https://github.com/Wechat-Group/WxJava) @@ -47,7 +47,7 @@ 1. 新手重要提示:本项目仅是一个SDK开发工具包,未提供Web实现,建议使用 `maven` 或 `gradle` 引用本项目即可使用本SDK提供的各种功能,详情可参考 **[【Demo项目】](demo.md)** 或本项目中的部分单元测试代码;另外微信开发新手请务必阅读[【开发文档 Wiki 首页】](https://github.com/Wechat-Group/WxJava/wiki)的常见问题部分,可以少走很多弯路,节省不少时间。 1. 技术交流群:想获得QQ群/微信群/钉钉企业群等信息的同学,请使用微信扫描上面的微信公众号二维码关注 `WxJava` 后点击相关菜单即可获取加入方式,同时也可以在微信中搜索 `weixin-java-tools` 或 `WxJava` 后选择正确的公众号进行关注,该公众号会及时通知SDK相关更新信息,并不定期分享微信Java开发相关技术知识; 1. 付费QQ群:(**注意:刚入群会有5分钟禁言,稍等片刻即可正常发言**) [![加入QQ群](https://img.shields.io/badge/QQ群-343954419-blue.svg)](http://shang.qq.com/wpa/qunwpa?idkey=731dc3e7ea31ebe25376cc1a791445468612c63fd0e9e05399b088ec81fd9e15) 或 [![加入QQ群](https://img.shields.io/badge/QQ群-343954419-blue.svg)](http://jq.qq.com/?_wv=1027&k=40lRskK),或者请自行搜索群号`343954419`进行添加;当然由于某种原因无法入群的,可关注公众号后获取其他群的加入方式; -1. 钉钉企业群:[请点击链接申请加入](https://h5.dingtalk.com/inviteColleague/index.html#/invite/9ed100cc4a/E1DF918E32E398D191E7FE61FE0552A6) 或者 [用手机钉钉APP扫码](https://gitee.com/binary/weixin-java-tools/raw/master/images/qrcodes/ding.jpg) 申请加入。 +1. 钉钉技术交流群: `30294972`。 1. 微信开发新手或者Java开发新手在群内提问或新开Issue提问前,请先阅读[【提问的智慧】](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/master/README-zh_CN.md),并确保已查阅过 [【开发文档Wiki】](https://github.com/wechat-group/WxJava/wiki) ,避免浪费大家的宝贵时间; 1. 寻求帮助时需贴代码或大长串异常信息的,请利用 http://paste.ubuntu.com @@ -111,6 +111,7 @@ - 专注批量推送的小而美的工具:https://github.com/rememberber/WePush - yshop意象商城系统:https://gitee.com/guchengwuyue/yshopmall - wx-manage(微信公众号管理项目):https://github.com/niefy/wx-manage +- 基于若依开发的微信公众号管理系统:https://gitee.com/joolun/JooLun-wx #### 小程序: - (京东)友家铺子,友家铺子店长版,京粉精选 diff --git a/demo.md b/demo.md index 2e29bb20..0d36db86 100644 --- a/demo.md +++ b/demo.md @@ -1,5 +1,5 @@ - ## `Demo` 项目 + ### 说明 1. 在码云和 `GitHub` 上均可访问,会尽量保持同步,请根据自己情况选用。 1. 一般来说,`Github`上的版本应该是最新的,但也有可能没及时同步,此种情况下请以 `Github` 上的版本为准,有问题也请在 `Github` 对应项目 `Issues` 页面提问)。 @@ -19,3 +19,4 @@ - 使用 `Spring MVC` 实现的公众号 Demo:[GitHub](http://github.com/binarywang/weixin-java-mp-demo-springmvc)、[码云](https://gitee.com/binary/weixin-java-mp-demo) [![Build Status](https://travis-ci.org/binarywang/weixin-java-mp-demo-springmvc.svg?branch=master)](https://travis-ci.org/binarywang/weixin-java-mp-demo-springmvc) - 使用 `Spring Boot` 实现的公众号 Demo(支持多公众号):[GitHub](http://github.com/binarywang/weixin-java-mp-demo-springboot)、[码云](http://gitee.com/binary/weixin-java-mp-demo-springboot) [![Build Status](https://travis-ci.org/binarywang/weixin-java-mp-demo-springboot.svg?branch=master)](https://travis-ci.org/binarywang/weixin-java-mp-demo-springboot) - 含公众号和部分微信支付代码的 Demo:[GitHub](http://github.com/Wechat-Group/weixin-java-demo-springmvc)、[码云](http://gitee.com/binary/weixin-java-tools-springmvc) [![Build Status](https://travis-ci.org/Wechat-Group/weixin-java-demo-springmvc.svg?branch=master)](https://travis-ci.org/Wechat-Group/weixin-java-demo-springmvc) + diff --git a/others/fenxiang.md b/others/fenxiang.md deleted file mode 100644 index 8b137891..00000000 --- a/others/fenxiang.md +++ /dev/null @@ -1 +0,0 @@ - diff --git a/weixin-java-cloudbase/README.md b/weixin-java-cloudbase/README.md new file mode 100644 index 00000000..495b8354 --- /dev/null +++ b/weixin-java-cloudbase/README.md @@ -0,0 +1,80 @@ +## 如何使用 `WxJava` 进行小程序云开发 + +[云开发(CloudBase)](https://www.cloudbase.net/)是基于Serverless架构构建的一站式后端云服务,涵盖函数、数据库、存储、CDN等服务,免后端运维,支持小程序、Web和APP开发。 +其中,小程序·云开发是微信和腾讯云联合推出的云端一体化解决方案,基于云开发可以免鉴权调用微信所有开放能力,在微信开发者工具中即可开通使用。 + +### 一、 引入`maven`依赖 + + +``` + + com.github.binarywang + weixin-java-miniapp + 3.7.1.B + +``` + + +### 二、 构造配置类,填入相关参数 + +``` + WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl(); + config.setAppid(...); // 微信小程序的appid + config.setSecret(...); // 微信小程序的Secret + config.setToken(...); // 微信小程序消息服务器配置的token,如果程序不涉及相关功能,可以忽略 + config.setAesKey(...); // 微信小程序消息服务器配置的EncodingAESKey,同上,如果不涉及,可以忽略 + config.setMsgDataFormat(...); // 消息数据格式,可以为XML或者JSON +``` + + +### 三、 构造service类,关联上述配置 + +``` + WxMaService wxMaService= new WxMaServiceImpl(); + + wxMaService.setWxMaConfig(config); +``` + +### 四、 根据小程序前端需要调用相应的方法: + +目前 `WxJava` 已支持当前所有接口(当然如果官方后续加入新接口,则还未在最新版本中实现,会考虑在之后版本中加入),所有已支持的接口列表可以参考在线`JavaDoc`:http://binary.ac.cn/weixin-java-miniapp-javadoc/cn/binarywang/wx/miniapp/api/WxMaCloudService.html + + +以触发云函数接口为例,可以采用如下方式调用 `invokeCloudFunction` 方法: + + +``` +String result = wxMaService.getCloudService().invokeCloudFunction("rcn", "login", "{}"); // 拿到result之后,可以在后续加入自己的处理逻辑代码 +``` + + +更多方法调用实例可以参考 `WxJava` 源码中的单元测试类:`cn.binarywang.wx.miniapp.api.impl.WxMaCloudServiceImplTest` + + +另外,顺便在此列出当前已支持云开发的方法如下: + +| 接口描述 | 方法名 | +| ---- | ---- | +| 删除文件 | batchDeleteFile(String env, String[] fileIds)| +| 获取文件下载链接 | batchDownloadFile(String env, String[] fileIds, long[] maxAges)| +| 数据库插入记录 | databaseAdd(String env, String query)| +| 数据库聚合记录 | databaseAggregate(String env, String query)| +| 新增集合 | databaseCollectionAdd(String env, String collectionName)| +| 删除集合 | databaseCollectionDelete(String env, String collectionName)| +| 获取特定云环境下集合信息 | databaseCollectionGet(String env, Long limit, Long offset)| +| 统计集合记录数或统计查询语句对应的结果记录数 | databaseCount(String env, String query)| +| 数据库删除记录 | databaseDelete(String env, String query)| +| 数据库导出 | databaseMigrateExport(String env, String filePath, int fileType, String query)| +| 数据库导入 | databaseMigrateImport(String env, String collectionName, String filePath, int fileType, boolean stopOnError, int conflictMode)| +| 数据库迁移状态查询 | databaseMigrateQueryInfo(String env, Long jobId)| +| 数据库查询记录 | databaseQuery(String env, String query)| +| 数据库更新记录 | databaseUpdate(String env, String query)| +| 获取腾讯云API调用凭证 | getQcloudToken(long lifeSpan)| +| 触发云函数 | invokeCloudFunction(String env, String name, String body)| +| 变更数据库索引 | updateIndex(String env, String collectionName, List createIndexes, List dropIndexNames)| +| 获取文件上传链接 | uploadFile(String env, String path)| + +### 五、 `Spring` 框架整合: + +可以参考https://github.com/binarywang/weixin-java-miniapp-demo 此项目整合 `Spring` 开发。 +此项目基于 `Spring Boot` ,如果需要支持`Spring MVC`项目,适当改造即可。