| | |
| | | private final static String appKey = "f9e7f22f"; |
| | | private final static String appSecret = "9B2291352497FAF42B2DF44BFCF62316"; |
| | | |
| | | //是否采用订单侠转链 |
| | | private final static boolean CONVERT_DINGDANXIA = true; |
| | | |
| | | /** |
| | | * 获取签名 |
| | | * |
| | |
| | | * @param goodsId |
| | | */ |
| | | public static VIPConvertResultDTO convertLink(String goodsId, String tag) { |
| | | |
| | | if (CONVERT_DINGDANXIA) { |
| | | return DingDanXiaApiUtil.convertLink(goodsId, tag); |
| | | } |
| | | |
| | | JSONObject taskParams = new JSONObject(); |
| | | JSONArray goodsIdArray = new JSONArray(); |
| | | goodsIdArray.add(goodsId); |
| | |
| | | taskParams.put("chanTag", tag); |
| | | taskParams.put("requestId", System.currentTimeMillis() + "_" + UUID.randomUUID()); |
| | | String result = baseRequest("com.vip.adp.api.open.service.UnionUrlService", "genByGoodsId", |
| | | JSONObject.fromObject(taskParams)); |
| | | System.out.println(result); |
| | | JSONObject resultJSON = JSONObject.fromObject(result); |
| | | if (resultJSON.optInt("returnCode") == 0) { |
| | | String re = resultJSON.optJSONObject("result").optJSONArray("urlInfoList").optJSONObject(0).toString(); |
| | | return new Gson().fromJson(re, VIPConvertResultDTO.class); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | public static VIPConvertResultDTO convertLinkByUrl(String url, String tag) { |
| | | |
| | | if (CONVERT_DINGDANXIA) { |
| | | return DingDanXiaApiUtil.convertLinkByUrl(url, tag); |
| | | } |
| | | JSONObject taskParams = new JSONObject(); |
| | | JSONArray urlArray = new JSONArray(); |
| | | urlArray.add(url); |
| | | taskParams.put("urlList", urlArray); |
| | | if (tag != null) { |
| | | taskParams.put("chanTag", tag); |
| | | } |
| | | taskParams.put("requestId", System.currentTimeMillis() + "_" + UUID.randomUUID()); |
| | | String result = baseRequest("com.vip.adp.api.open.service.UnionUrlService", "genByVIPUrl", |
| | | JSONObject.fromObject(taskParams)); |
| | | System.out.println(result); |
| | | JSONObject resultJSON = JSONObject.fromObject(result); |
| | |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | |
| | | convertLink("6919237495414585303","437032"); |
| | | |
| | | convertLinkByUrl("https://t.vip.com/T7RyKKCJLj9", "437032"); |
| | | } |
| | | |
| | | } |