|
|
package com.yoho.core;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yoho.search.base.utils.MD5Util;
|
|
|
import com.yoho.search.base.utils.HttpClientUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
public class TblProductUrlTest {
|
|
|
public static void main(String[] args) {
|
|
|
StringBuffer url = new StringBuffer();
|
|
|
url.append("http://service.api.tbl.yohobuy.com/product/api/v1/detail/");
|
|
|
url.append("getproductslistforsearch?client_type=iphone");
|
|
|
url.append("&limit=" + 0);
|
|
|
url.append("&offset=" + 500);
|
|
|
|
|
|
StringBuffer param = new StringBuffer();
|
|
|
param.append("client_type=iphone");
|
|
|
param.append("&limit=" + 0);
|
|
|
param.append("&offset=" + 500);
|
|
|
param.append("&private_key=" + "a85bb0674e08986c6b115d5e3a4884fa");
|
|
|
String md5 = MD5Util.string2MD5(param.toString());
|
|
|
|
|
|
url.append("&client_secret=" + md5);
|
|
|
|
|
|
System.out.println(url);
|
|
|
|
|
|
String json = HttpClientUtils.getMethod(url.toString());
|
|
|
if (StringUtils.isBlank(json)) {
|
|
|
throw new RuntimeException("json is null");
|
|
|
}
|
|
|
JSONObject jsonObject = JSON.parseObject(json);
|
|
|
String data = jsonObject.getString("data");
|
|
|
if (StringUtils.isBlank(data)) {
|
|
|
throw new RuntimeException("data is null");
|
|
|
}
|
|
|
System.out.println(JSONArray.parseArray(jsonObject.getString("data"), Map.class));
|
|
|
}
|
|
|
} |