小程序手机号解析接口一直报 412 Precondition Failed: [no body]?
public String getPhoneNumber(String phoneCode) {
JSONObject params = new JSONObject();
params.put("code", phoneCode);
String url = MessageFormat.format("https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token={0}", getAccessToken());
JSONObject reObj = restTemplate.postForObject(url, params, JSONObject.class);
if (reObj != null && reObj.containsKey("errcode")) {
log.info(reObj.toJSONString());
if (reObj.getInteger("errcode") == 0) {
Code2PhoneNumberResponse code2PhoneNumberResponse = JSONObject.parseObject(reObj.toJSONString(), Code2PhoneNumberResponse.class);
return code2PhoneNumberResponse.getPhoneInfo().getPurePhoneNumber();
}
}
return null;
}