| | |
| | | } |
| | | |
| | | |
| | | public static PDDPromotionUrl convertResourceUrl(String pid) { |
| | | /** |
| | | * 活动转链 https://open.pinduoduo.com/application/document/api?id=pdd.ddk.resource.url.gen |
| | | * |
| | | * @param resourceType |
| | | * @param url |
| | | * @param pid |
| | | * @param customParams |
| | | * @return |
| | | */ |
| | | public static PDDConvertLinkResultVO convertActivity(String resourceType, String url, String pid, String customParams) { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("type", "pdd.ddk.resource.url.gen"); |
| | | map.put("pid", pid); |
| | | map.put("resource_type", "39998"); |
| | | map.put("url", "https://mobile.yangkeduo.com/attendance.html?_pdd_fs=1&_pdd_tc=ffffff&_pdd_sbs=1&type=1&id=155075"); |
| | | if (customParams != null) { |
| | | map.put("custom_parameters", customParams); |
| | | } |
| | | map.put("resource_type", resourceType); |
| | | if (url != null) { |
| | | map.put("url", url); |
| | | } |
| | | |
| | | String result = baseRequest(map); |
| | | JSONObject root = JSONObject.fromObject(result); |
| | | JSONObject json = root.optJSONObject("resource_url_response"); |
| | | if (json == null) { |
| | | return null; |
| | | } |
| | | JSONObject urlJSON = json.optJSONObject("single_url_list"); |
| | | PDDConvertLinkResultVO vo = null; |
| | | Gson gson = new GsonBuilder().disableHtmlEscaping().create(); |
| | | if (urlJSON != null) { |
| | | |
| | | vo = gson.fromJson(urlJSON.toString(), PDDConvertLinkResultVO.class); |
| | | } |
| | | JSONObject weAppInfo = json.optJSONObject("we_app_info"); |
| | | if (weAppInfo != null && vo != null) { |
| | | PDDConvertLinkResultVO.WeAppInfoBean weAppInfoBean = gson.fromJson(weAppInfo.toString(), PDDConvertLinkResultVO.WeAppInfoBean.class); |
| | | vo.setWe_app_info(weAppInfoBean); |
| | | } |
| | | |
| | | return vo; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 频道推广(https://open.pinduoduo.com/application/document/api?id=pdd.ddk.cms.prom.url.generate) |
| | | * |
| | | * @param channelType |
| | | * @param pid |
| | | * @param customParams |
| | | * @return |
| | | */ |
| | | |
| | | public static PDDConvertLinkResultVO convertChannel(String channelType, String pid, String customParams) { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("type", "pdd.ddk.cms.prom.url.generate"); |
| | | map.put("p_id_list", "[\"" + pid + "\"]"); |
| | | if (customParams != null) { |
| | | map.put("custom_parameters", customParams); |
| | | } |
| | | map.put("channel_type", channelType); |
| | | map.put("generate_mobile", true+""); |
| | | map.put("generate_short_url", true+""); |
| | | map.put("generate_we_app", true+""); |
| | | |
| | | |
| | | |
| | | String result = baseRequest(map); |
| | | System.out.println(result); |
| | | return null; |
| | | JSONObject root = JSONObject.fromObject(result); |
| | | JSONObject json = root.optJSONObject("cms_promotion_url_generate_response"); |
| | | if (json == null) { |
| | | return null; |
| | | } |
| | | JSONObject urlJSON = json.optJSONArray("url_list").optJSONObject(0); |
| | | PDDConvertLinkResultVO vo = null; |
| | | Gson gson = new GsonBuilder().disableHtmlEscaping().create(); |
| | | if (urlJSON != null) { |
| | | vo = gson.fromJson(urlJSON.toString(), PDDConvertLinkResultVO.class); |
| | | } |
| | | |
| | | return vo; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 微信小程序转链 @Title: convertWXMP @Description: @param goodsId @param |
| | |
| | | // PDDConvertLinkResultVO vo = getAuthLink(PID_SHARE, PinDuoDuoUtil.getCustomParams(437032l)); |
| | | // |
| | | // System.out.println(vo); |
| | | PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(227873724698L); |
| | | // PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(227873724698L); |
| | | |
| | | PDDConvertLinkResultVO vo = convertChannel("0", PID_DEFAULT, null); |
| | | |
| | | PinDuoDuoApiUtil.convert(goods.getGoodsSign(), PID_DEFAULT + "","437032", false); |
| | | System.out.println(vo); |
| | | // PinDuoDuoApiUtil.convert(goods.getGoodsSign(), PID_DEFAULT + "", "437032", false); |
| | | } |
| | | } |