0
点赞
收藏
分享

微信扫一扫

c#.net淘宝客基础api练手日记

 

淘宝客基础api练手日记

第一步:​​SDK 下载​​

​​http://open.taobao.com/doc.htm?spm=a219a.7386653.0.0.ae9foK&docId=101618&docType=1​​

SDK文件目录:

c#.net淘宝客基础api练手日记_json

把下载好的SDK放到项目web的bin文件夹下

只放:TopSdk.dll 文件即可

第二步:项目中引入SDK

c#.net淘宝客基础api练手日记_json_02

第三步:获取 App Key和App Secret


 

第四步:cs文件代码

淘宝客商品详情(简版)

​​http://open.taobao.com/api.htm?docId=24518&docType=2&scopeId=11655​​

public partial class ceshi_taobaoke_api : System.Web.UI.Page
{
public static string appUrl = " http://gw.api.taobao.com/router/rest";
public static string appKey = "appKey";
public static string appSecret = "appSecret";

protected void Page_Load(object sender, EventArgs e)
{

Label1.Text =TaoBaoShow("524176904993",1L,"61.52.68.39","json")+"<br>";
Label1.Text+="\n\n\n"+TaoBaoShow("524176904993",1L,"61.52.68.39","xml");


}

#region 淘宝客商品详情(简版)----------------------------
/// <summary>
/// 淘宝客商品详情 (简版)
/// </summary>
/// <param name="NumIids">商品ID串,用,分割,最大40个</param>
/// <param name="Platform"> 链接形式:1:PC,2:无线,默认:1</param>
/// <param name="Ip">ip地址,影响邮费获取,如果不传或者传入不准确,邮费无法精准提供</param>
/// <param name="format">格式:XML或JSON</param>
public static string TaoBaoShow(string NumIids, Int64 Platform, string Ip, string format)
{
ITopClient client = new DefaultTopClient(appUrl, appKey, appSecret,format);
TbkItemInfoGetRequest req = new TbkItemInfoGetRequest();
req.NumIids =NumIids;
req.Platform = Platform;
req.Ip = Ip;
TbkItemInfoGetResponse rsp = client.Execute(req);
return rsp.Body;
}
#endregion

}

第五步:返回数据

json 数据

{
"tbk_item_info_get_response": {
"results": {
"n_tbk_item": [{
"cat_leaf_name": "卫衣\/绒衫",
"cat_name": "女装\/女士精品",
"item_url": "https:\/\/item.taobao.com\/item.htm?id=524176904993",
"material_lib_type": "1",
"nick": "FREEMEIGE原创自由派潮女装",
"num_iid": 524176904993,
"pict_url": "https:\/\/img.alicdn.com\/bao\/uploaded\/i2\/102467811\/TB2AcJ3grFkpuFjy1XcXXclapXa_!!102467811.jpg",
"provcity": "广东 广州",
"reserve_price": "189",
"seller_id": 102467811,
"small_images": {
"string": ["https:\/\/img.alicdn.com\/i1\/102467811\/TB2Br4DguJ8puFjy1XbXXagqVXa_!!102467811.jpg", "https:\/\/img.alicdn.com\/i1\/TB1TV50KpXXXXb.XVXXXXXXXXXX_!!0-item_pic.jpg", "https:\/\/img.alicdn.com\/i2\/102467811\/TB2uAx1gq8lpuFjy0FpXXaGrpXa_!!102467811.jpg", "https:\/\/img.alicdn.com\/i1\/102467811\/TB2ki9BXyKO.eBjSZPhXXXqcpXa_!!102467811.jpg"]
},
"title": "2018秋季新款 个性女装宽松卫衣显瘦原宿风斗篷外套加厚蝙蝠衫潮",
"user_type": 0,
"volume": 93,
"zk_final_price": "189"
}]
},
"request_id": "4ifd06xkqzre"
}
}

xml数据

<?xml version="1.0" encoding="utf-8" ?>
<tbk_item_info_get_response>
<results>
<n_tbk_item>
<cat_leaf_name>卫衣/绒衫</cat_leaf_name>
<cat_name>女装/女士精品</cat_name>
<item_url>https://item.taobao.com/item.htm?id=524176904993</item_url>
<material_lib_type>1</material_lib_type>
<nick>FREEMEIGE原创自由派潮女装</nick>
<num_iid>524176904993</num_iid>
<pict_url>https://img.alicdn.com/bao/uploaded/i2/102467811/TB2AcJ3grFkpuFjy1XcXXclapXa_!!102467811.jpg</pict_url>
<provcity>广东 广州</provcity>
<reserve_price>189</reserve_price>
<seller_id>102467811</seller_id>
<small_images>
<string>https://img.alicdn.com/i1/102467811/TB2Br4DguJ8puFjy1XbXXagqVXa_!!102467811.jpg</string>
<string>https://img.alicdn.com/i1/TB1TV50KpXXXXb.XVXXXXXXXXXX_!!0-item_pic.jpg</string>
<string>https://img.alicdn.com/i2/102467811/TB2uAx1gq8lpuFjy0FpXXaGrpXa_!!102467811.jpg</string>
<string>https://img.alicdn.com/i1/102467811/TB2ki9BXyKO.eBjSZPhXXXqcpXa_!!102467811.jpg</string>
</small_images>
<title>2018秋季新款 个性女装宽松卫衣显瘦原宿风斗篷外套加厚蝙蝠衫潮</title>
<user_type>0</user_type>
<volume>93</volume>
<zk_final_price>189</zk_final_price>
</n_tbk_item>
</results>
<request_id>hetegfay8x96</request_id>
</tbk_item_info_get_response>
<!--top011183249188.na62-->

举报

相关推荐

0 条评论