node-wx-mp

1.0.0 • Public • Published

node-wx-mp

node 微信小程序服务端相关接口

微信文档参考地址

https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/mp-access-token/getAccessToken.html

Install 安装

use npm isntall

使用 npm 安装

npm install node-wx-mp

已对接接口(具体说明需要查看微信文档,穿参例子看获取手机号,appid,secret,access_token三个参数均无需传递,其余参数放在对象内传入即可,键名同微信参数)

code2Session: 'https://api.weixin.qq.com/sns/jscode2session',(小程序登录) getPluginOpenPId: 'https://api.weixin.qq.com/wxa/getpluginopenpid?access_token=',(获取插件用户openpid) getPhoneNumber: 'https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=',(获取手机号) getQRCode: 'https://api.weixin.qq.com/wxa/getwxacode?access_token=',(获取小程序码) getUnlimitedQRCode: 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=',(获取不限制的小程序码) createQRCode: 'https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=',(获取小程序二维码) generateUrlLink: 'https://api.weixin.qq.com/wxa/generate_urllink?access_token=',(获取加密URLLink) generateShortLink: 'https://api.weixin.qq.com/wxa/genwxashortlink?access_token=',(获取ShortLink)

Sample example 使用说明

init Client 初始化客户端

/**
 * 初始化工具客户端
 * @author xutao
 * @param    {[String]}                 appid [小程序唯一凭证,即 AppID]
 * @param    {[String]}                 secret [小程序唯一凭证密钥,即 AppSecret]
*/
const wechatMp = require('node-wx-mp').initClient({
    appid: appid,
    secret: secret,
})

例子

获取手机号

/**
 * 获取手机号
 * @param {String} params.code [手机号获取凭证]
*/
wechatMp.getPhoneNumber({code:code})
.then(function (body){
	console.log(body);
})
.catch(function (err){
	console.log(err);
});

Readme

Keywords

none

Package Sidebar

Install

npm i node-wx-mp

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

18.3 kB

Total Files

6

Last publish

Collaborators

  • bluedtao