微信公众号授权
2017-11-14 本文已影响0人
__Max__
备注:
appId 公众号的唯一标识
timestamp 生成签名的时间戳
nonceStr 生成签名的随机串
signature 签名
jsApiList 需要使用的JS接口列表
微信文档 https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115
获取权限签名成功分5步



1. wx.config需要的参数是从后端接口获取,appId 、timestamp 、nonceStr 、signature,(前三者前端可以写死或者自行计算获得,但是安全问题不推荐)
2.关于signature 签名 的sha1加密算法,算法有现成的加密插件google即可,重要的是string1的字符串拼接必须和文档一样,string1中的noncestr的s是小写,(wx.config的参数noneStr中s是大写),附上官方签名的验证链接https://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=jsapisign
3.wx.config签名成功后自动执行wx.ready,签名失败则自动执行wx.error.



ps:分享用的方形图链接必须是一个完整的url链接。需要先把分享图片先行上传到线上。