行业知识
小程序 获取 手机号 47001 data format error hint
2026-11-17 16:23:43
来源:互联网转载
0.场景
后���获取小程序用户手机号 ,api文档
()https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/user-info/phone-number/getPhoneNumber.html
使用hutool工具作为http client
()1. 正确的写法
正确示例
String tencentUrl = StringUtils.format("https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token={}",access_token); HashMap paramMap = new HashMap(1); paramMap.put("code",jsonRes.getStr("code")); String jsonStr =JsonUtils.toJsonString(paramMap); HttpResponse httpResponse = HttpRequest.post(tencentUrl) .body(jsonStr).execute();