获取小程序新增或活跃用户的画像分布数据服务端接口
//POST https://api.weixin.qq.com/datacube/getweanalysisappiduserportrait?access_token=ACCESS_TOKEN
String accessToken = MiniUtisl.getAccessToken("wxc5b9d706d2b4f8e6", "xxxxxxxxxxxxxxxxxxxxxxxx", redisTemplate);
System.out.println("access_token:"+accessToken);
Map<String, Object> paramsMap = Maps.newHashMap();
// paramsMap.put("access_token",accessToken);
paramsMap.put("begin_date","20210321");
paramsMap.put("end_date","20210321");
String post = HttpClientUtil.doPost(MiniConstans.GETWEANALYSISAPPIDUSERPORTRAIT+"?access_token="+accessToken, paramsMap);
// String resultStr = HttpUtil.httpMethodPost(MiniConstans.GETWEANALYSISAPPIDUSERPORTRAIT+"?access_token="+accessToken, paramsMap,"utf-8");
System.out.println(post);
public static String doPost(String url, Map<String, Object> params) throws ClientProtocolException, IOException {
HttpClient httpclient = getConnection();
String result = null;
HttpPost httpPost = new HttpPost(url);
HttpResponse response = null;
httpPost.setConfig(requestConfig);
List<NameValuePair> pairList = new ArrayList<>(params.size());
for (Map.Entry<String, Object> entry : params.entrySet()) {
NameValuePair pair = new BasicNameValuePair(entry.getKey(), entry
.getValue().toString());
pairList.add(pair);
}
httpPost.setEntity(new UrlEncodedFormEntity(pairList, Charset.forName(encoding)));
response = httpclient.execute(httpPost);
InputStream in = response.getEntity().getContent();
result = IOUtils.toString(in, encoding);
in.close(); //in.close()作用是将用完的连接释放,下次请求可以复用。如果是response.close();结果就是连接会被关闭,并且不能被复用
return result;
}
返回报文:{"errcode":47001,"errmsg":"data format error rid: 60588512-2d7dcf44-36249691"}
你好,经查询 rid: 60588512-2d7dcf44-36249691,请求包为 begin_date=20210321
请更换json格式 再重新调用试试