From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 25 二月 2025 16:41:22 +0800 Subject: [PATCH] 淘宝转链接口更新 --- fanli/src/main/java/com/yeshi/fanli/util/goods/douyin/CSJCPSApiUtil.java | 52 ++++++++++++++++++++++++++++++++++------------------ 1 files changed, 34 insertions(+), 18 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/util/goods/douyin/CSJCPSApiUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/goods/douyin/CSJCPSApiUtil.java index 1ff7cd2..53a1203 100644 --- a/fanli/src/main/java/com/yeshi/fanli/util/goods/douyin/CSJCPSApiUtil.java +++ b/fanli/src/main/java/com/yeshi/fanli/util/goods/douyin/CSJCPSApiUtil.java @@ -10,6 +10,7 @@ import org.apache.commons.httpclient.methods.PostMethod; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.yeshi.utils.JsonUtil; import org.yeshi.utils.StringUtil; import org.yeshi.utils.TimeUtil; @@ -25,7 +26,7 @@ * @date 2022/8/8 15:45 */ public class CSJCPSApiUtil { - private static Logger debugLog=LoggerFactory.getLogger("debugLog"); + private static Logger debugLog = LoggerFactory.getLogger("debugLog"); private static String post(String url, String entity) { HttpClient client = new HttpClient(); @@ -49,7 +50,7 @@ private static String baseRequest(String path, JSONObject data, CSJAppInfo appInfo) { String url = "http://ecom.pangolin-sdk-toutiao.com" + path; - debugLog.info("鎶栭煶璇锋眰寮�濮嬶細閾炬帴-{}",url); + debugLog.info("鎶栭煶璇锋眰寮�濮嬶細閾炬帴-{}", url); com.alibaba.fastjson.JSONObject params = new com.alibaba.fastjson.JSONObject(); params.put("app_id", appInfo.getAppId()); @@ -261,7 +262,7 @@ * @param: extra_info 濯掍綋浼犻�掓墿灞曞弬鏁扮殑瀛楁锛� 瀛楃鍙厑璁稿瓧夂熲激饧╁啓銆佹暟瀛椼�� 涓嬪垝绾匡紝饣撳害涓嶈秴杩�20 * @param: product_ext 鍟嗗搧鎼滅储鎺モ紳杩斿洖鐨� product.ext 瀛楁, 灏介噺濉啓 **/ - public static DYConvertResult goodsConvert(String product_url, String extra_info, String product_ext) { + public static DYConvertResult goodsConvert(String product_url, String extra_info, String product_ext) throws Exception { JSONObject data = new JSONObject(); data.put("product_url", product_url); data.put("external_info", extra_info); @@ -269,17 +270,18 @@ //杞摼绫诲瀷锛�1銆佹姈饩� deep link锛�2銆佹姈 //饩斥紗缁寸爜锛�3銆佹姈饩斥紳浠ゃ�� //榛樿杩斿洖鎶栤境deeplink - data.put("share_type", "[1,2,3]"); + data.put("share_type", "[1,3,4]"); String result = baseRequest("/product/link", data); System.out.println(result); JSONObject resultJson = JSONObject.fromObject(result); if (resultJson.optInt("code") != 0) { - return null; + throw new Exception(resultJson.optString("desc")); } JSONObject dataJson = resultJson.optJSONObject("data"); DYConvertResult bean = new DYConvertResult(); bean.setDeeplink(dataJson.optString("dy_deeplink")); bean.setPassword(dataJson.optString("dy_password")); + bean.setZlink(dataJson.optString("dy_zlink")); if (dataJson.optJSONObject("dy_qr_code") != null) { bean.setQrCode(dataJson.optJSONObject("dy_qr_code").optString("url")); @@ -385,19 +387,33 @@ } - public static void main(String[] args) { -// DYOrderFilter filter=new DYOrderFilter(); -// filter.setTime_type("update"); -// filter.setOrder_type(1); -// filter.setSize(50); -// filter.setCursor("0"); -// filter.setStart_time(TimeUtil.convertToTimeTemp("2022-12-18","yyyy-MM-dd")/1000); -// filter.setEnd_time(TimeUtil.convertToTimeTemp("2022-12-19","yyyy-MM-dd")/1000); -// -// DYOrderResult result = orderList(filter); -// System.out.println(result); - goodsDetails(Arrays.asList(new Long[]{3549871967593209780L})); - // DYOrder order = getOrderDetail("5005828634543277401", 1); + public static JSONObject parseCommand(String command) { + JSONObject data = new JSONObject(); + data.put("command", command); + String result = baseRequest("/command_parse", data); + System.out.println(result); + JSONObject resultJson = JSONObject.fromObject(result); + if (resultJson.optInt("code") != 0) { + return null; + } + JSONObject dataJson = resultJson.optJSONObject("data"); + return dataJson; + } + + public static String parseProductId(String command) { + JSONObject result = parseCommand(command); + if (result != null) { + if (result.optInt("command_type") == 1) { + return result.optJSONObject("product_info").optString("product_id"); + } + } + return null; + } + + + public static void main(String[] args) throws Exception { + DYConvertResult result = goodsConvert("https://v.douyin.com/iNTutNyn/","123","132"); + System.out.printf(result.toString()); } -- Gitblit v1.8.0