package com.taobao.api; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.taobao.api.request.ItemGetRequest; import com.taobao.api.request.ItemcatsGetRequest; import com.taobao.api.request.ShopGetRequest; import com.taobao.api.request.TaobaokeItemsGetRequest; import com.taobao.api.response.ItemGetResponse; import com.taobao.api.response.ItemcatsGetResponse; import com.taobao.api.response.ShopGetResponse; import com.taobao.api.response.TaobaokeItemsGetResponse; public class APITest { protected static String url = "http://gw.api.taobao.com/router/rest";// 沙箱环境调用地址 // 正式环境需要设置为:http://gw.api.taobao.com/router/rest // http://gw.api.tbsandbox.com/router/rest protected static String appkey = "你的key"; protected static String appSecret = "你的secret"; public static void main(String[] args) { // APITest.testItemGet(); // getShopInfo(); getItems(); // getItem(); } /** * 获取所有类别目录 */ public static void testItemGet() { TaobaoClient client = new DefaultTaobaoClient(url, appkey, appSecret); ItemcatsGetRequest req = new ItemcatsGetRequest(); req.setFields("cid,parent_cid,name,is_parent"); req.setParentCid(0L); // req.setCids("18957,19562,"); ItemcatsGetResponse response = null; try { response = client.execute(req); } catch (ApiException e) { e.printStackTrace(); } } /** * sid 店铺编号。shop+sid.taobao.com即店铺地址,如shop123456.taobao.com * * @param cid * 123456 店铺所属的类目编号 * @param nick * 卖家昵称 * @param title * 店铺标题 * @param desc * 店铺描述 * @param bulletin * 店铺公告 * @param pic_path * 店标地址。返回相对路径,可以用"http://logo.taobao.com/shop-logo"来拼接成绝对路径 * @param created * 开店时间。格式:yyyy-MM-dd HH:mm:ss * @param modified * 最后修改时间。格式:yyyy-MM-dd HH:mm:ss * @param shop_score * 店铺动态评分信息(item_score:商品描述评分;service_score:服务态度评分;delivery_score * :发货速度评分;) */ public static void getShopInfo() { TaobaoClient client = new DefaultTaobaoClient(url, appkey, appSecret); ShopGetRequest req = new ShopGetRequest(); req.setFields("shop_score,sid,cid,title,nick,desc,bulletin,pic_path,created,modified"); req.setNick("hemp619"); ShopGetResponse response = null; try { response = client.execute(req); } catch (ApiException e) { e.printStackTrace(); } String body = response.getBody(); JSONObject obj = JSON.parseObject(body); String shop_get_response = obj.get("shop_get_response") + ""; JSONObject obj2 = JSON.parseObject(shop_get_response); String shop = obj2.get("shop") + ""; JSONObject obj3 = JSON.parseObject(shop); String title = obj3.get("pic_path") + ""; System.out.println(title); } /** * 获取指定用户所有宝贝 */ public static void getItems() { TaobaoClient client = new DefaultTaobaoClient(url, appkey, appSecret); TaobaokeItemsGetRequest req = new TaobaokeItemsGetRequest(); req.setNick("terryang"); req.setCid(0l); req.setFields("num_iid,title,nick,pic_url,price,click_url,commission,commission_rate,commission_num,commission_volume,shop_click_url,seller_credit_score,item_location,volume"); TaobaokeItemsGetResponse response = null; try { response = client.execute(req); } catch (ApiException e) { e.printStackTrace(); } } /** * 获取宝贝详情 * * @see 返回参数说明 * http://api.taobao.com/apidoc/dataStruct.htm?path=cid:4-dataStructId * :63 -apiId:20-invokePath:item */ public static void getItem() { TaobaoClient client = new DefaultTaobaoClient(url, appkey, appSecret); ItemGetRequest req = new ItemGetRequest(); req.setFields("detail_url,num_iid,title,nick,type,cid,seller_cids,props,input_pids,input_str,desc,pic_url,num,valid_thru,list_time,delist_time,stuff_status,location,price,post_fee,express_fee,ems_fee,has_discount,freight_payer,has_invoice,has_warranty,has_showcase,modified,increment,approve_status,postage_id,product_id,auction_point,property_alias,item_img,prop_img,sku,video,outer_id,is_virtual"); req.setNumIid(1500008334147L); ItemGetResponse response = null; try { response = client.execute(req, null); } catch (ApiException e) { e.printStackTrace(); } } }

leyx0121 LV1
3月26日
13332222 LV1
2023年4月3日
lhchun LV2
2023年2月22日
admin3366998855 LV2
2022年3月23日
zhubeihongbenny LV4
2022年3月5日
781681653 LV1
2022年2月15日
刘亦菲9527 LV15
2021年12月27日
awen123 LV2
2021年10月10日
lichang714 LV2
2021年10月8日
十一不是一一 LV1
2021年10月6日