-
Notifications
You must be signed in to change notification settings - Fork 96
API
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 withquery.signature. -
getAccessToken, callback {function}, thecallbackwill be called after getting the accessToken from wechat server. -
getWechatTicket, [accessToken {string}, callback {function}], pass theaccessTokento get thejsticket. -
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, passforce:trueto 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}],infoinclude 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
getSignatureByURLandcreateNewSignatureare 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,codeparam 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 beforegetUserInfo.