package com.ks.tool.bkz.util.tb;
|
|
import com.ks.tool.bkz.util.HttpUtil;
|
import com.ks.tool.bkz.vo.tb.ZheTaoKeConvertResult;
|
import net.sf.json.JSONObject;
|
|
import java.util.HashMap;
|
import java.util.Map;
|
|
public class ZheTaoKeApiUtil {
|
|
private static String baseRequest(String baseUrl, Map<String, String> params) {
|
params.put("appkey", "fe65b15d74d84c75b99578543da75264");
|
String result = HttpUtil.get(baseUrl, params, null);
|
return result;
|
}
|
|
/**
|
* 获取淘口令
|
* @param auctionId
|
* @return
|
*/
|
public static ZheTaoKeConvertResult getTkl(Long auctionId) {
|
try {
|
Map<String, String> params = new HashMap<>();
|
params.put("sid", "34116");
|
params.put("pid", "mm_106929643_20324269_81478350");
|
params.put("num_iid", auctionId + "");
|
params.put("signurl", 5 + "");
|
String result = baseRequest("https://api.zhetaoke.com:10001/api/open_gaoyongzhuanlian.ashx", params);
|
JSONObject resultJson = JSONObject.fromObject(result);
|
if (resultJson.optInt("status") == 200) {
|
JSONObject item= resultJson.optJSONArray("content").optJSONObject(0);
|
return new ZheTaoKeConvertResult(item.optString("taobao_url"),item.optString("tkl"),item.optLong("tao_id"));
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
|
}
|