wx-mp-api
v0.2.10
Published
A library for Node.js app access WeChat/Weixin MP platform service.
Downloads
18
Maintainers
Readme
wx-mp-api
wx-mp-api is an interface for node.js to access WeChat MP platform service. wx-mp-api utilize Bluebird to support promise.
##Install
npm install wx-mp-api
##Usage
Create instance:
An example for Express:
##Methods ###buildWXPageAPIConfig(url) While JavaScript in page try to call WeChat/Wexin bridge, WeChat should verify the page privilege, this method build an object to pass to the front, then wx.config can accept it. return: { "noncestr": "1QNBVBx2u02AGQ0HO1lOeEuggQeYID2e", "timestamp": "1476328755", "signature": "03a4...", "appId": "******...", "jsApiList": ["checkJsApi", "openAddress"] }
###verifySite(signature,timestamp,nonce); While binding the Web application to your WeChat MP account, WeChat will send a verfification request to the application, the application should verrify the request and response an echo str. This function is a simple encapsulation.
Usage in Express:
###buildWXAuthURL(url,method) method could be 'sns_base' or 'sns_userinfo'
###requreUserInfo() Retrieve the user information.
###requreOpenId(code) WeChat only pass "code" as a query param to web app, app should retrieve the user infomation from WeChat through WeChat service reqeust.
###requestQRTicket This method is used by requestQR.
###requestQR Sometime, app want to generate QR code, WeChat provice a service to help it. Call this function to generate QR through WeChat service.
###createMenu WeChat MP support customized menu, you can create menu through this function in your route function.
Todo:
- to support more interfaces
If you need more interface, please let me know.