访问
https://api.weixin.qq.com/datacube/getweanalysisappiddailyvisittrend?access_token=ACCESS_TOKEN
预期返回的数据为
{ "list": [
{ "ref_date": "20170313", "session_cnt": 142549, "visit_pv": 472351, "visit_uv": 55500, "visit_uv_new": 5464, "stay_time_session": 0, "visit_depth": 1.9838
}
]
}
我这边实际返回
{“list”:[]}
代码如下:
public String testPvApi() throws Exception {
//先获取token
String url = ConstantUtil.ACCESS_TOKEN_URL+"&"+“appid=”+ConstantUtil.APPID+"&"+“secret=”+ConstantUtil.SECRET;
String result = HttpUtils.get(url);
JsonObject fromJson = JsonUtils.fromJson(result, JsonObject.class);
//System.out.println(result);
String accessToken = fromJson.get(“access_token”).getAsString();
System.out.println("newToken: " + accessToken);
RedisManager.set(ConstantUtil.ACCESS_TOKEN, accessToken, ConstantUtil.ACCESS_TOKEN_EXPIRE_TIME);
System.out.println(RedisManager.get(ConstantUtil.ACCESS_TOKEN));
// String accessToken = RedisManager.get(ConstantUtil.ACCESS_TOKEN);
//日访问数据的url
String dayUrl = ConstantUtil.DAY_STATISTICS_URL+accessToken;
JSONObject jsonObject = new JSONObject();
long now = DateUtil.dateToZeroTimeStamp(new Date());
long yesterday = now - 60 * 60;
//获得时间格式为20180612的昨日时间
String yesStr = DateUtil.getDays(yesterday);
jsonObject.put(“begin_date”, yesStr);
jsonObject.put(“end_date”, yesStr);
//查询昨日的数据
String dayStatics = PostJsonUtil.getJsonData(jsonObject, dayUrl);
System.out.println(dayStatics);