weixin-node
微信(wechat)签名等后端接口封装(nodejs)
USAGE
- getToken
通过 appid
和 secret
获取 access_token
+ **appid**
+ **secret**
+ expires_in 强制指定缓存时间(默认缓存 7200 秒)
+ update 是否强制服务端更新缓存
return
{ access_token: 'yqtqCpfmJOnbJM6i2_JeWK_-r28jvIgO0Pzk66IXpFXRKVqrrDoqCXrOE4G1wgGiSERMKQ2qTH7l9xwDD1O--bxxLh8ahXbgrhx67o4qUZ0',
expires_in: 7200 }
- getTicket
通过 access_token
获取 ticket
+ **access_token**
+ expires_in 强制指定缓存时间(默认缓存 7200 秒)
+ update 是否强制服务端更新缓存
return
{ errcode: 0,
errmsg: 'ok',
ticket: 'sM4AOVdWfPE4DxkXGEs8VDsWI7B-faDW7RPMNI7CBMYBwrOO_HqeX3cazP-FRv1zclArJLDw2_0WQA604Sc-GA',
expires_in: 7200 }
- sign
微信官方签名算法
+ **ticket**
+ **url**
return
{ jsapi_ticket: 'sM4AOVdWfPE4DxkXGEs8VDsWI7B-faDW7RPMNI7CBMYBwrOO_HqeX3cazP-FRv1zclArJLDw2_0WQA604Sc-GA',
nonceStr: '564m6gkt2dbwqao',
timestamp: '1426509920',
url: 'http://weixin.com',
signature: 'fd0079efb712acfdcc0a398b85c74102f1cd1ef1' }
example
simple
var weixin = var co =
sign a url, just need appid
+ secret
{ var query = thisquery var token = weixin iftokenerrcode return thisbody = token var ticket = weixin ifticketerrcode !== 0 return thisbody = ticket var result = weixin resultappId = queryappid thisbody = result}