JSONObject param = new JSONObject();
param.put("code",code);
String result2 = HttpRequest.post("https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token="+accessToken)
.form(param)//表单内容
.timeout(20000)//超时,毫秒
.execute().body();
String result = HttpUtil.post("https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token="+accessToken, param);
是的,写的有问题,请求payload要求是JSON字符串,要显式声明请求头 content-type: application/json,你用的httpclient默认的content-type应该是 application/x-www-form-urlencoded,所以两种方式都不对