node 微信小程序服务端相关接口
https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/mp-access-token/getAccessToken.html
use npm isntall
使用 npm 安装
npm install node-wx-mp
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)
/**
* 初始化工具客户端
* @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);
});