| | |
| | | /** |
| | | * 获取商品详情,简版 |
| | | * |
| | | * @param id |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | public static List<TaoBaoGoodsBrief> getBatchGoodsInfos(String ids) throws TaobaoGoodsDownException { |
| | |
| | | // 从转链搜索 |
| | | TaoBaoGoodsBrief newGoods = specialConvertCoupon(goods.getAuctionId(), |
| | | new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET, |
| | | TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT)); |
| | | TaoBaoConstant.TAOBAO_PID_DEFAULT)); |
| | | |
| | | if (newGoods != null) { |
| | | goods.setTkRate(newGoods.getTkRate()); |
| | |
| | | // 从转链搜索 |
| | | TaoBaoGoodsBrief newGoods = specialConvertCoupon(goods.getAuctionId(), |
| | | new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET, |
| | | TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT)); |
| | | TaoBaoConstant.TAOBAO_PID_DEFAULT)); |
| | | |
| | | if (newGoods != null) { |
| | | goods.setTkRate(newGoods.getTkRate()); |
| | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 从淘宝链接中解析商品ID(高级接口) |
| | | * |
| | | * @param link |
| | | * @return |
| | | */ |
| | | public static String parseAuctionIdFromLink(String link) { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("method", "taobao.tbk.item.click.extract"); |
| | | map.put("click_url", link + ""); |
| | | |
| | | TaoKeAppInfo app = new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET, |
| | | TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID); |
| | | JSONObject resultJSON = null; |
| | | try { |
| | | resultJSON = TaoKeBaseUtil.baseRequest(map, app); |
| | | System.out.println(resultJSON); |
| | | } catch (TaoKeApiException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (resultJSON == null) |
| | | return null; |
| | | |
| | | return null; |
| | | |
| | | } |
| | | |
| | | public static String getAccessToken(String code, String appKey, String appSecret) { |
| | | Map<String, String> map = new HashMap<>(); |
| | |
| | | |
| | | } |
| | | |
| | | public static void taoKeContent() { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("method", "taobao.tbk.content.get"); |
| | | map.put("adzone_id", TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT.split("_")[3]); |
| | | map.put("type", "1"); |
| | | map.put("count", "100"); |
| | | |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY); |
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET); |
| | | try { |
| | | JSONObject json = TaoKeBaseUtil.baseRequest(map, app); |
| | | System.out.println(json); |
| | | } catch (TaoKeApiException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public static void taoKeContentSource(String contentId, String source) { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("method", "taobao.tbk.dg.optimus.material"); |
| | | map.put("adzone_id", TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT.split("_")[3]); |
| | | map.put("page_size", "10"); |
| | | map.put("page_no", "1"); |
| | | map.put("content_id", contentId); |
| | | map.put("content_source", source); |
| | | map.put("material_id", "1"); |
| | | |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY); |
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET); |
| | | try { |
| | | JSONObject json = TaoKeBaseUtil.baseRequest(map, app); |
| | | System.out.println(json); |
| | | } catch (TaoKeApiException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | // AA5ISJ |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | public static void getTaoKeContentEffective() { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("method", "taobao.tbk.dg.optimus.material"); |
| | | map.put("adzone_id", TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID.split("_")[3]); |
| | | map.put("page_no", "1"); |
| | | map.put("page_size", "20"); |
| | | map.put("content_id", "8872035"); |
| | | |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY); |
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET); |
| | | try { |
| | | JSONObject json = TaoKeBaseUtil.baseRequest(map, app); |
| | | System.out.println(json); |
| | | } catch (TaoKeApiException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | public static void getTaoKeContent() { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("method", "taobao.tbk.content.get"); |
| | | map.put("adzone_id", TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID.split("_")[3]); |
| | | map.put("type", "1"); |
| | | |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY); |
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET); |
| | | try { |
| | | JSONObject json = TaoKeBaseUtil.baseRequest(map, app); |
| | | System.out.println(json); |
| | | } catch (TaoKeApiException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 淘口令转商品ID |
| | | * |
| | |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("method", "taobao.tbk.tpwd.convert"); |
| | | map.put("password_content", token); |
| | | map.put("adzone_id", TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT.split("_")[3]); |
| | | map.put("adzone_id", TaoBaoConstant.TAOBAO_PID_DEFAULT.split("_")[3]); |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY); |
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET); |
| | |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("method", "taobao.tbk.itemid.coupon.get"); |
| | | map.put("platform", 2 + ""); |
| | | map.put("pid", TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID); |
| | | map.put("pid", TaoBaoConstant.TAOBAO_PID_DEFAULT); |
| | | map.put("num_iids", auctionId + ""); |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY); |
| | |
| | | map.put("method", "taobao.tbk.itemid.coupon.get"); |
| | | map.put("platform", auctionId + ""); |
| | | map.put("num_iids", auctionId + ""); |
| | | map.put("pid", TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT); |
| | | map.put("pid", TaoBaoConstant.TAOBAO_PID_DEFAULT); |
| | | |
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); |
| | | JSONObject resultJSON = null; |
| | | try { |
| | | resultJSON = TaoKeBaseUtil.baseRequest(map, new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, |
| | | TaoBaoConstant.TAOBAO_AUTH_APPSECRET, TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT)); |
| | | TaoBaoConstant.TAOBAO_AUTH_APPSECRET, TaoBaoConstant.TAOBAO_PID_DEFAULT)); |
| | | |
| | | JSONObject response = resultJSON.optJSONObject("tbk_dg_optimus_material_response"); |
| | | if (response != null && response.optJSONObject("result_list") != null) { |