From 81da61b828e29b7745e1382dfbbaeb685dc083ef Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 23 一月 2024 17:17:55 +0800 Subject: [PATCH] 抖音转链修改 --- fanli/src/main/java/com/yeshi/fanli/util/goods/douyin/CSJCPSApiUtil.java | 33 ++++++++++++++++++++++++++++----- 1 files changed, 28 insertions(+), 5 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 8c5fdeb..56ca1e3 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 @@ -270,7 +270,7 @@ //杞摼绫诲瀷锛�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); @@ -281,6 +281,7 @@ 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")); @@ -386,11 +387,33 @@ } + 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 { - DYGoodsDetail goods = CSJCPSApiUtil.goodsDetail(Long.parseLong("3629012100619309031")); - DYConvertResult link = CSJCPSApiUtil.goodsConvert(goods.getDetail_url(), DYUtil.createFanLiExtraInfo(437032L), - ""); - System.out.println(link); + String id = parseProductId("https://v.douyin.com/iLQybbqP/"); + System.out.printf(id); } -- Gitblit v1.8.0