Skip to content
jason edited this page Mar 29, 2016 · 16 revisions

Welcome to the wechat-jssdk API wiki! ###Initialize

//get your wechat info from wechat dashboard
var wechatInfo = {
  "wechatToken": "aaa",
  "appId": "bbb",
  "appSecret": "ccc"
}
var wx = require('wechat-jssdk');
wx.initialize(wechatInfo);

###JS-SDK APIs
Call api: wx.jssdk.fun()

  • verifySignature, [query {object}], JSON object containing all the verification properties, including: timestamp, nonce, to generate the signature to which to compare with query.signature.
  • getAccessToken, callback {function}, the callback will be called after getting the accessToken from wechat server.
  • getWechatTicket, [accessToken {string}, callback {function}], pass the accessToken to get the jsticket.
  • updateAccessTokenOrTicketGlobally, [token {string}, ticket{string}, callback {function}], update global token and ticket, it will update every 2 hours, usually we don't need to update it manually.
  • getNewTokenAndTicket, [callback {function}, force {boolean}], get new global token and ticket, pass force:true to force getting the info, otherwise, it will only allow to get this at most 5 times within 2 hours.
  • prepareNewSignature, [callback {function}], get or generate global token info for signature generating process.
  • genSignature, [ticket {string}, url {string}, token {string}], generate the url signature with the provided info.
  • saveNewSignature, [info {object}, callback {function}], info include all the signature information for the specific url.
  • updateSignatureByUrl, [url {string}, info {object}, callback {function}], update the signature by existing url.
  • getSignatureByURL, [url {string}, callback {function}], get the signature form cache or create a new one, usually this is the most used api.
  • createNewSignature, [url {string}, callback {function}, force {boolean}], create a new signature now.
  • getTokenFromCache, [url {string}], just get url signature from cache.

Usually getSignatureByURL and createNewSignature are the only two apis you need to call.

###OAuth APIs
Call api: wx.oauth.fun()

  • getUserBaseInfo, [code {string}, callback {function}], get wechat user base info, code param is included in the wechat redirect url.
  • getUserInfo, [code {string}, callback {function}], get wechat user info, including nickname, openid, avatar, etc...
  • getOAuthAccessToken, [code {string}, callback {function}], get oauth access token, you need to get this info before getUserInfo.

Clone this wiki locally