2010/01/19新增功能:
1. 修正旺旺API返回结果不正确的问题
2. 修正JSON解释带换行符结果的问题
下载地址:
1. Google Code: http://top4net.googlecode.com/files/taobao-sdk-net-20110119.zip
2. 官方下载地址:
http://dl.open.taobao.com/sdk/taobao-sdk-net.zip
相比Top4Net,官方版的SDK主要包含以下特性:
1. 更直观和方便的调用方式
2. 使用IsError的方式取代抛异常
3. 支持所有API(包括旺旺,淘江湖。。。)
4. 直接通过源码就可以查看文档描述
5. XML解释性能提升
6.
支持JSON解释(基于.NET 2.0)
调用示例:
1) 获取用户公开数据
- ITopClient client = new DefaultTopClient("http://gw.api.taobao.com/router/rest", "appkey", "appsecret", "xml");
- UserGetRequest req = new
- req.Fields = "user_id,nick,created,buyer_credit,type,sex";
- req.Nick = "helloworld";
- UserGetResponse rsp = client.Execute(req);
- if (rsp.IsError)
- {
- // 异常处理
- }
- Console.WriteLine(rsp.Body);
2) 添加一个商品
- ITopClient client = new DefaultTopClient("http://gw.api.taobao.com/router/rest", "appkey", "appsecret", "json");
- ItemAddRequest req = new
- req.ApproveStatus = "onsale";
- req.ListTime = DateTime.Now;
- req.Num = 100L;
- req.Price = "88.00";
- req.Type = "fixed";
- req.StuffStatus = "new";
- req.Title = "iphone4 v5";
- req.Desc = "how are you doing";
- req.LocationState = "浙江";
- req.LocationCity = "杭州";
- req.FreightPayer = "buyer";
- req.PostFee = "12.00";
- req.ExpressFee = "6.00";
- req.OuterId = "100001";
- req.Cid = 2203L;
- req.Props = "20000:44506;1627207:3232484;20055:27842";
- req.Image = new
- ItemAddResponse rsp = client.Execute(req, "sessionKey");
- Console.WriteLine(rsp.Body);
3) 增量订单下载
- ITopClient client = new DefaultTopClient("http://gw.api.taobao.com/router/rest", "appkey", "appsecret", "json");
- TradesSoldIncrementGetRequest req = new
- req.StartModified = DateTime.Parse("2010-10-13 00:00:00");
- req.EndModified = DateTime.Parse("2010-10-13 23:59:59");
- req.UseHasNext = true;
- req.PageNo = 1;
- req.PageSize = 10;
- req.Fields = "tid,buyer_nick,seller_nick,modified,orders.iid,orders.title,orders.price";
- TradesSoldIncrementGetResponse rsp = null;
- do
- {
- rsp = client.Execute(req, "sessionKey");
- req.PageNo++;
- Console.WriteLine(rsp.Body);
- } while (rsp != null && rsp.HasNext);
4) 查询物流跟踪信息
- ITopClient client = new DefaultTopClient("http://gw.api.taobao.com/router/rest", "appkey", "appsecret", "json");
- LogisticsTraceSearchRequest req = new
- req.SellerNick = "奥迅运动户外专营店";
- req.Tid = 55070989240898L;
- LogisticsTraceSearchResponse rsp = client.Execute(req);
- Console.WriteLine(rsp.Body);