惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
P
Palo Alto Networks Blog
D
Docker
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
Schneier on Security
Engineering at Meta
Engineering at Meta
I
InfoQ
L
LangChain Blog
Cyberwarzone
Cyberwarzone
T
Tenable Blog
WordPress大学
WordPress大学
P
Privacy & Cybersecurity Law Blog
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Jina AI
Jina AI
C
CERT Recently Published Vulnerability Notes
Scott Helme
Scott Helme
博客园 - 三生石上(FineUI控件)
酷 壳 – CoolShell
酷 壳 – CoolShell
Know Your Adversary
Know Your Adversary
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The Last Watchdog
The Last Watchdog
Last Week in AI
Last Week in AI
Cloudbric
Cloudbric
S
SegmentFault 最新的问题
爱范儿
爱范儿
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 叶小钗
AI
AI
T
Tor Project blog
I
Intezer
T
Threatpost
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V
Visual Studio Blog
N
News and Events Feed by Topic
Latest news
Latest news
S
Security Affairs
博客园 - Franky
Microsoft Security Blog
Microsoft Security Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
B
Blog RSS Feed
C
Cybersecurity and Infrastructure Security Agency CISA
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
S
Securelist

博客园 - 大山008

若依导出excel时decimal数据千分位格式化 SpringBoot如何引入deepseek-多轮对话 EasyExcel实现百万级数据导入导出 SpringAMQP整合RabbitMQ使用 win11安装redis步骤详解 ftp与sftp工具类 stream流的一些常用用法 子类的toString方法如何打印父类的属性 MySQL常见的几种优化方案 关于若依AsyncFactory的一些思考,记录一下 Vue 路由跳转、路由传参、跳转区别、传值取值 MYSQL中substring_index()用法 mybatis sql 解决 in 参数过多的问题 MySQL之json数据操作 mybatis查询返回map键值对的问题 validate校验,记录一种思路 在vue中用multipart/form-data方式上传文件并同表单同步提交数据 生成带有二维码的海报 java将指定文件夹下面的所有图片压缩到指定大小以内并保存图片 Lock与ReentrantLock、Synchronized
Java微信转发及网络检测
大山008 · 2023-02-03 · via 博客园 - 大山008

1、jar包引入

<dependency>
         <groupId>com.github.binarywang</groupId>
         <artifactId>weixin-java-mp</artifactId>
         <version>4.2.0</version>
 </dependency>
<!--微信支付-->
 <dependency>
         <groupId>com.github.binarywang</groupId>
         <artifactId>weixin-java-pay</artifactId>
         <version>4.2.0</version>
</dependency>

2、yml文件配置(参数可查微信开发者文档)

wx:
  pay:
    #公众号微信支付
    appId: **********
    mchId: *****
    mchKey: ****
    subAppId:
    subMchId:
    keyPath: classpath:apiclient_cert.p12
    spbillCreateIp: 39.105.71.11
  mp:
    #公众号
    appId: ****8
    secret: *****
    token:
    aesKey:

3、实现转发分享功能

参考文档:https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html

注意JSSDK接口不是随便就能调用的,在页面初始化阶段,需要注入接口权限验证,上一篇我们其实已经实现了,即如下方法

//返回初始化参数    
@PostMapping("/getJsApiTicket")
    public AjaxResult getJsApiTicket(String url) {
        log.debug("getJsonApi url:{}", url);
        try {
            WxJsapiSignature jsapiSignature = wxMpService.createJsapiSignature(url);
            Map map = new HashMap(2);
            map.put("js", jsapiSignature);
            log.info("js=============" + jsapiSignature);
            return AjaxResult.success(map);
        } catch (WxErrorException e) {
            log.error("获取网络状态参数错误:{}", e.getMessage());
            return AjaxResult.error();
        }
    }

页面初始化

wx.config({
    debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
    appId: result.data.js.appId, // 必填,公众号的唯一标识
    timestamp: result.data.js.timestamp, // 必填,生成签名的时间戳
    nonceStr: result.data.js.nonceStr, // 必填,生成签名的随机串
    signature: result.data.js.signature,// 必填,签名
    jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData','getNetworkType'] // 必填,需要使用的JS接口列表
});

分享朋友或者qq及网络检测

wx.ready(function () {   //需在用户可能点击分享按钮前就先调用
  wx.updateAppMessageShareData({ 
    title: '', // 分享标题
    desc: '', // 分享描述
    link: '', // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
    imgUrl: '', // 分享图标
    success: function () {
      // 设置成功
    }
  })
});

分享朋友圈及qq空间

wx.ready(function () {      //需在用户可能点击分享按钮前就先调用
  wx.updateTimelineShareData({ 
    title: '', // 分享标题
    link: '', // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
    imgUrl: '', // 分享图标
    success: function () {
      // 设置成功
    }
  })
});

网络检测

网络检测
wx.getNetworkType({
    success: function (res) {
        
    }
})