1、官方文档 https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140839
2、我的核心代码
/*** 根据openid获取用户详情* @param {*} request * @param {*} h */
userInfoByOpenId: async function (request, h) {const { openid } = request.params;const access_token = await getAccessToken();const result = await superagent.get('https://api.weixin.qq.com/cgi-bin/user/info').query({access_token,openid});const data = JSON.parse(result.text);return data;
}
3、测试结果