.net淘宝客基础api 分页查询

  1 using System;
  2 using System.Collections.Generic;
  3 using System.Configuration;
  4 using System.Linq;
  5 using System.Web;
  6 using Top.Api;
  7 using Top.Api.Request;
  8 using Top.Api.Response;
  9
 10 namespace MvcWebApp.DataBase
 11 {
 12     public class TaoDataProvider
 13     {
 14
 15         public static string appKey = ConfigurationManager.AppSettings["appKey"].ToString();
 16         public static string appSecret = ConfigurationManager.AppSettings["appSecret"].ToString();
 17         public static string appUrl = "http://gw.api.taobao.com/router/rest";
 18
 19         //淘宝官方接口说明:http://open.taobao.com/doc2/apiDetail.htm?spm=a219a.7395905.0.0.70naXx&scopeId=11655&apiId=26619
 20
 21         /// <summary>
 22         /// 关键字查询商品
 23         /// </summary>
 24         /// <param name="PageIndex"></param>
 25         /// <param name="PageSize"></param>
 26         /// <param name="queryKey"></param>
 27         /// <returns></returns>
 28         public static string query(int PageIndex, int PageSize, string queryKey)
 29         {
 30             ITopClient client = new DefaultTopClient(appUrl, appKey, appSecret, "json");
 31             TbkItemGetRequest req = new TbkItemGetRequest();
 32             req.Fields = "num_iid,title,pict_url,small_images,reserve_price,zk_final_price,user_type,provcity,item_url";
 33             req.Q = queryKey;
 34             req.Platform = 1L;
 35             req.PageNo = PageIndex;
 36             req.PageSize = PageSize;
 37             TbkItemGetResponse response = client.Execute(req);
 38             return response.Body;
 39         }
 40         /// <summary>
 41         /// 分页查询
 42         /// </summary>
 43         /// <param name="PageIndex"></param>
 44         /// <param name="PageSize"></param>
 45         /// <param name="queryKey"></param>
 46         /// <param name="totalCount"></param>
 47         /// <param name="pageNum"></param>
 48         /// <returns></returns>
 49         public static List<Top.Api.Domain.NTbkItem> query(int PageIndex, int PageSize, string queryKey, out long totalCount, out long pageNum)
 50         {
 51             totalCount = 0;
 52             pageNum = 0;
 53             ITopClient client = new DefaultTopClient(appUrl, appKey, appSecret);
 54
 55             TbkItemGetRequest req = new TbkItemGetRequest();
 56             req.Fields = "num_iid,title,pict_url,small_images,reserve_price,zk_final_price,user_type,provcity,item_url";
 57             req.Q = queryKey;
 58             req.Platform = 1L;
 59             req.PageNo = PageIndex;
 60             req.PageSize = PageSize;
 61
 62             TbkItemGetResponse response = client.Execute(req);
 63
 64             totalCount = response.TotalResults;
 65             pageNum = (long)Math.Ceiling(totalCount / (double)PageSize);
 66             return response.Results;
 67         }
 68         /// <summary>
 69         /// 分页查询商品
 70         /// </summary>
 71         /// <param name="PageIndex">当前页</param>
 72         /// <param name="PageSize">每页多少条</param>
 73         /// <param name="queryKey">关键字</param>
 74         /// <param name="cat">后台类目ID16,18</param>
 75         /// <param name="itemloc">所在地</param>
 76         /// <param name="sort">排序_des降序.排序_asc升序.排序销量total_sales淘客佣金比率tk_rate累计推广量tk_total_sales总支出佣金tk_total_commi</param>
 77         /// <param name="isTmall">是否商城商品</param>
 78         /// <param name="isOverseas">是否海外商品</param>
 79         /// <param name="startPrice">折扣价范围下限</param>
 80         /// <param name="endPrice">折扣价范围上限</param>
 81         /// <param name="startTkRate">淘客佣金比率上限</param>
 82         /// <param name="endTkRate">淘客佣金比率下限</param>
 83         /// <param name="totalCount">总条数</param>
 84         /// <param name="pageNum">总页数</param>
 85         /// <returns></returns>
 86         public static List<Top.Api.Domain.NTbkItem> query(int PageIndex, int PageSize, string queryKey,
 87             string cat, string itemloc, string sort, bool? isTmall, bool? isOverseas, long? startPrice, long? endPrice,
 88             long? startTkRate, long? endTkRate,
 89             out long totalCount, out long pageNum)
 90         {
 91             totalCount = 0;
 92             pageNum = 0;
 93             ITopClient client = new DefaultTopClient(appUrl, appKey, appSecret);
 94
 95             TbkItemGetRequest req = new TbkItemGetRequest();
 96             req.Fields = "num_iid,title,pict_url,small_images,reserve_price,zk_final_price,user_type,provcity,item_url";
 97             if (!string.IsNullOrWhiteSpace(queryKey)) req.Q = queryKey;
 98             req.Platform = 1;
 99             req.PageNo = PageIndex;
100             req.PageSize = PageSize;
101
102             if (!string.IsNullOrWhiteSpace(cat)) req.Cat = cat;//后台类目ID16,18
103             if (!string.IsNullOrWhiteSpace(itemloc)) req.Itemloc = itemloc;//所在地
104             if (!string.IsNullOrWhiteSpace(sort)) req.Sort = sort;//"tk_rate_des";//排序
105             if (isTmall.HasValue) req.IsTmall = isTmall;//是否商城商品
106             if (isOverseas.HasValue) req.IsOverseas = isOverseas;//是否海外商品
107             if (startPrice.HasValue) req.StartPrice = startPrice;//    折扣价范围下限
108             if (endPrice.HasValue) req.EndPrice = endPrice;
109             if (startTkRate.HasValue) req.StartTkRate = startTkRate;//淘客佣金比率上限,如:1234表示12.34%
110             if (endTkRate.HasValue) req.EndTkRate = endTkRate;
111
112
113
114             TbkItemGetResponse response = client.Execute(req);
115
116             totalCount = response.TotalResults;
117             pageNum = (long)Math.Ceiling(totalCount / (double)PageSize);
118             return response.Results;
119         }
120
121
122         /// <summary>
123         /// 根据ID查询单个商品
124         /// </summary>
125         /// <param name="ssid"></param>
126         /// <returns></returns>
127         public static string FindOne(string ssid)
128         {
129             ITopClient client = new DefaultTopClient(appUrl, appKey, appSecret, "json");
130             TbkItemInfoGetRequest req = new TbkItemInfoGetRequest();
131             req.Fields = "num_iid,title,pict_url,small_images,reserve_price,zk_final_price,user_type,provcity,item_url";
132             req.Platform = 1L;
133             req.NumIids = ssid;
134             TbkItemInfoGetResponse rsp = client.Execute(req);
135             return rsp.Body;
136         }
137         /// <summary>
138         /// 根据ID查询单个商品
139         /// </summary>
140         /// <param name="ssid">123,256,365(最多40个)</param>
141         /// <returns></returns>
142         public static List<Top.Api.Domain.NTbkItem> FindBySSID(string ssid)
143         {
144             ITopClient client = new DefaultTopClient(appUrl, appKey, appSecret);
145             TbkItemInfoGetRequest req = new TbkItemInfoGetRequest();
146             req.Fields = "num_iid,title,pict_url,small_images,reserve_price,zk_final_price,user_type,provcity,item_url";
147             req.Platform = 1L;
148             req.NumIids = ssid;
149             TbkItemInfoGetResponse rsp = client.Execute(req);
150             return rsp.Results;
151         }
152         /// <summary>
153         /// 关联商品查询
154         /// </summary>
155         /// <param name="relate_type"></param>
156         /// <param name="num_iid"></param>
157         /// <param name="count"></param>
158         /// <param name="platform"></param>
159         /// <returns></returns>
160         public static string FindListRelevance(int? relate_type, long? num_iid, int? count = 24, int? platform = 1)
161         {
162             ITopClient client = new DefaultTopClient(appUrl, appKey, appSecret, "json");
163             TbkItemRecommendGetRequest req = new TbkItemRecommendGetRequest();
164             req.Fields = "num_iid,title,pict_url,small_images,reserve_price,zk_final_price,user_type,provcity,item_url";
165
166             if (num_iid.HasValue)
167                 req.NumIid = num_iid.Value;
168
169             //req.Cat = 123L;
170             req.Count = count.Value;
171             req.Platform = platform.Value;
172             TbkItemRecommendGetResponse rsp = client.Execute(req);
173             //Console.WriteLine(rsp.Body);
174             return rsp.Body;
175         }
176         /// <summary>
177         /// 关联商品查询
178         /// </summary>
179         /// <param name="relate_type"></param>
180         /// <param name="num_iid"></param>
181         /// <param name="count"></param>
182         /// <param name="platform"></param>
183         /// <returns></returns>
184         public static List<Top.Api.Domain.NTbkItem> FindListRelate(int? relate_type, long? num_iid, int? count = 24, int? platform = 1)
185         {
186             ITopClient client = new DefaultTopClient(appUrl, appKey, appSecret);
187             TbkItemRecommendGetRequest req = new TbkItemRecommendGetRequest();
188
189             req.Fields = "num_iid,title,pict_url,small_images,reserve_price,zk_final_price,user_type,provcity,item_url";
190             //if (relate_type.HasValue)
191             //    req.RelateType = relate_type.Value;
192             if (num_iid.HasValue)
193                 req.NumIid = num_iid.Value;
194
195             //req.Cat = 123L;
196             req.Count = count.Value;
197             req.Platform = platform.Value;
198             TbkItemRecommendGetResponse rsp = client.Execute(req);
199             //Console.WriteLine(rsp.Body);
200             return rsp.Results;
201         }
202         /// <summary>
203         /// 获取淘宝客店铺列表
204         /// </summary>
205         /// <param name="PageIndex">第几页</param>
206         /// <param name="PageSize">每页几条</param>
207         /// <param name="queryKey">关键字</param>
208         /// <param name="start_credit">信用等级下限,1~20</param>
209         /// <param name="end_credit">信用等级上限,1~20</param>
210         /// <param name="start_commission_rate">淘客佣金比率下限,1~10000</param>
211         /// <param name="end_commission_rate">淘客佣金比率上限,1~10000</param>
212         /// <param name="start_total_action">店铺商品总数下限</param>
213         /// <param name="end_total_action">店铺商品总数上限</param>
214         /// <param name="start_auction_count">累计推广商品下限</param>
215         /// <param name="end_auction_count">累计推广商品上限</param>
216         /// <param name="totalCount">总数</param>
217         /// <param name="pageNum">总页数</param>
218         /// <returns></returns>
219         public static List<Top.Api.Domain.NTbkShop> FindShopsPagedList(long PageIndex, long PageSize, string queryKey,
220             long? start_credit, long? end_credit, long? start_commission_rate, long? end_commission_rate,
221             long? start_total_action, long? end_total_action, long? start_auction_count, long? end_auction_count,
222             out long totalCount, out long pageNum)
223         {
224             ITopClient client = new DefaultTopClient(appUrl, appKey, appSecret);
225             TbkShopGetRequest req = new TbkShopGetRequest();
226             req.Fields = "click_url,pic_url,seller_nick,shop_title,shop_url,user_id";
227             if (!string.IsNullOrWhiteSpace(queryKey)) req.Q = queryKey;
228             if (start_credit.HasValue) req.StartCredit = start_credit;
229             if (end_credit.HasValue) req.EndCredit = end_credit;
230
231             if (start_commission_rate.HasValue) req.StartCommissionRate = start_commission_rate;
232             if (end_commission_rate.HasValue) req.EndCommissionRate = end_commission_rate;
233
234             if (start_total_action.HasValue) req.StartTotalAction = start_total_action;
235             if (end_total_action.HasValue) req.EndTotalAction = end_total_action;
236
237             if (start_auction_count.HasValue) req.StartAuctionCount = start_auction_count;
238             if (end_auction_count.HasValue) req.EndAuctionCount = end_auction_count;
239
240             req.PageNo = PageIndex;
241             req.PageSize = PageSize;
242             TbkShopGetResponse rsp = client.Execute(req);
243
244             totalCount = rsp.TotalResults;
245             pageNum = (long)Math.Ceiling(totalCount / (double)PageSize);
246             return rsp.Results;
247
248
249         }
250         /// <summary>
251         /// 淘宝客店铺关联推荐查询
252         /// </summary>
253         /// <param name="userid">卖家Id</param>
254         /// <returns></returns>
255         public static List<Top.Api.Domain.NTbkShop> GetShopRecommend(long userid)
256         {
257
258             ITopClient client = new DefaultTopClient(appUrl, appKey, appSecret);
259             TbkShopRecommendGetRequest req = new TbkShopRecommendGetRequest();
260             req.Fields = "click_url,pict_url,seller_nick,shop_title,shop_type,shop_url,user_id";
261             req.UserId = userid;
262             req.Count = 20;
263             req.Platform = 1;
264             TbkShopRecommendGetResponse rsp = client.Execute(req);
265             return rsp.Results;
266
267         }
268         /// <summary>
269         /// 枚举正在进行中的定向招商的活动列表
270         /// </summary>
271         /// <returns></returns>
272         public static List<Top.Api.Domain.TbkEvent> GetTbkUatmEvent(long? pageindex = 1, long? pageSize = 20)
273         {
274             ITopClient client = new DefaultTopClient(appUrl, appKey, appSecret);
275             TbkUatmEventGetRequest req = new TbkUatmEventGetRequest();
276             req.PageNo = pageindex;
277             req.PageSize = pageSize;
278             req.Fields = "event_id,event_title,start_time,end_time";
279             TbkUatmEventGetResponse rsp = client.Execute(req);
280             return rsp.Results;
281         }
282         /// <summary>
283         /// 获取淘宝联盟定向招商的宝贝信息
284         /// </summary>
285         /// <param name="event_id"></param>
286         /// <param name="pageindex"></param>
287         /// <param name="pageSize"></param>
288         /// <returns></returns>
289         public static List<Top.Api.Domain.UatmTbkItem> GetTbkUatmEventItem(long event_id, long? pageindex = 1, long? pageSize = 20)
290         {
291             ITopClient client = new DefaultTopClient(appUrl, appKey, appSecret);
292             TbkUatmEventItemGetRequest req = new TbkUatmEventItemGetRequest();
293             req.Platform = 1L;
294             req.PageSize = pageSize;
295             //req.AdzoneId = 34567L;
296             //req.Unid = unid;
297             req.EventId = event_id;
298             req.PageNo = pageindex;
299             req.Fields = "num_iid,title,pict_url,small_images,reserve_price,zk_final_price,user_type,provcity,item_url,seller_id,volume,nick,shop_title,zk_final_price_wap,event_start_time,event_end_time,tk_rate,type,status";
300             TbkUatmEventItemGetResponse rsp = client.Execute(req);
301             return rsp.Results;
302
303         }
304         /// <summary>
305         /// 获取淘宝联盟选品库列表
306         /// </summary>
307         /// <param name="type">默认值-1;选品库类型,1:普通选品组,2:高佣选品组,-1,同时输出所有类型的选品组</param>
308         /// <param name="pageindex"></param>
309         /// <param name="pageSize"></param>
310         /// <returns></returns>
311         public static List<Top.Api.Domain.TbkFavorites> GetTbkUatmFavorites(long? type=-1, long? pageIndex = 1, long? pageSize = 20)
312         {
313             ITopClient client = new DefaultTopClient(appUrl, appKey, appSecret);
314             TbkUatmFavoritesGetRequest req = new TbkUatmFavoritesGetRequest();
315             req.PageNo = pageIndex;
316             req.PageSize = pageSize;
317             req.Fields = "favorites_title,favorites_id,type";
318             req.Type = type;
319             TbkUatmFavoritesGetResponse rsp = client.Execute(req);
320             return rsp.Results;
321         }
322         /// <summary>
323         /// 指定选品库id,获取该选品库的宝贝信息
324         /// </summary>
325         /// <param name="FavoritesId"></param>
326         /// <param name="pageIndex"></param>
327         /// <param name="pageSize"></param>
328         /// <returns></returns>
329         public static List<Top.Api.Domain.UatmTbkItem> GetTbkUatmFavoritesItem(long? FavoritesId, long? pageIndex = 1, long? pageSize = 20)
330         {
331             ITopClient client = new DefaultTopClient(appUrl, appKey, appSecret);
332             TbkUatmFavoritesItemGetRequest req = new TbkUatmFavoritesItemGetRequest();
333             req.Platform = 1L;
334             req.PageSize = pageSize;
335             //req.AdzoneId = 34567L;
336             //req.Unid = "3456";
337             req.FavoritesId = FavoritesId;
338             req.PageNo = pageIndex;
339             req.Fields = "num_iid,title,pict_url,small_images,reserve_price,zk_final_price,user_type,provcity,item_url,seller_id,volume,nick,shop_title,zk_final_price_wap,event_start_time,event_end_time,tk_rate,status,type";
340             TbkUatmFavoritesItemGetResponse rsp = client.Execute(req);
341             return rsp.Results;
342         }
343
344
345     }
346 }
时间: 2024-10-10 09:30:29

.net淘宝客基础api 分页查询的相关文章

使用 Python 全栈打造淘宝客微信机器人(上)

本篇  将会涉及: Python 环境下淘宝客 API 的使用: 使用 Python 第三方模块 itchat 实现微信的登录的自动回复操作: PyQt5 的布局管理与多线程应用 1 .前言 1.1.什么是淘宝客 相信很多人都听过或者接触过各类导购 APP.QQ 群.微信群分享一些淘宝商品的优惠券或是其他的优惠信息. 用户可以在这些渠道上获取到相较于从淘宝平台搜索出来的商品更加优惠的价格或者是领取到面额较大的优惠券. 这些渠道,都是属于淘宝客的渠道.淘宝客是淘宝平台推出的一种按成交计费的推广模式

Java实现HMacMD5加密,用于淘宝客JS 组件 API 调用时生成 sign 的签名

原文:Java实现HMacMD5加密,用于淘宝客JS 组件 API 调用时生成 sign 的签名 源代码下载地址:http://www.zuidaima.com/share/1550463397874688.htm HMacMD5 加密纯 Java 实现,用于淘宝客 JS 组件 API 调用时生成 sign 的签名 另外:给大家贴一段淘宝客组件 API (JS API) 调用时,生成签名的核心代码. 另外:从事淘宝客开发的童鞋,碰到啥问题可以找我交流!!! String timestamp =

查询类网站或成站长淘宝客新金矿

流量是玩转互联网的基础,传说的中的大牛一般都是倒腾流量的高手.在大牛眼中抓取流量是一门艺术,背后玩的是五花八门的思路. 这篇文章斗胆跟大家分享一个好玩的思路.文章将以剥洋葱的方式展开,希望剥完这颗洋葱会让你有相见恨晚之感. 在切入正题之前,先分析一下搜索需求这个概念.人们借助搜索引擎大抵有以下几个诉求:第一,了解是什么,寻找是什么类别的信息,这一块占据搜索流量的绝大部分.第二,想知道为什么,很多时候会用提问关键词去索引,譬如"怎么获取流量".第三类,单纯地想去某个网站,敲入关键词通过搜

淘宝客知道这几个ID,收入将会提高50%

基础问题天天说,天天有人问.这篇文章写点基础的.特别对新手的帮助会很大哦. 1,PID,做淘宝客不知道PID,赚到钱也会被冻结. 如何手动获取PID 2,单品ID,淘宝商品的唯一识别编号,和身份证一样,每个商品都有个唯一的编号 天猫的 https://detail.tmall.com/item.htm?id=520105375809&ali_refid=a3_430583_1006:1103424533:N:%E4%B8%93%E4%B8%9A%E6%B3%B3%E8%A1%A3%E5%A5%B

淘宝客公众号探路

一.初衷 开发淘宝客公众号有一段时间, 现在初见雏形, 正式启用, 慢慢有订单了, 赚个零用钱花花. 现在公众号的创建门槛很低, 捣鼓两下, 创建菜单, 关联好网站地址就OK了, 作为一个程序员肯定不能满足于此. 当时设计时包含的一些特色功能: 1.对接微信红包,  作为引流, 以及提供用户的购买积极性 2.自动查找优惠券功能 3.添加订单,自动计算佣金 4.对接一些三方推广库, 定时生成特定的网页, 网页包含实时淘口令 二.遇到的坑 做开发肯定会遇到各种各样的问题, 解决就好了, 开发的过程中

李星:O2O平台复制淘宝客模式,能否走出烧钱买流量泥潭?

"流量"是互联网经济的生存土壤,移动互联网相对比固定互联网开辟了门槛更低.用户基数更多的流量"增量"市场,随着TMT成为扎堆创业的热门,移动互联网也成为新的流量"存量"市场,而这酿成O2O等成为去年的烧钱专业户. O2O作为打通线上与线下的商业模式,是无数实体门店以及传统行业从业者转型升级的寄托,岂可因噎废食?!从近年的教训看,主打用户忠诚度的模式很逃补贴的旋涡.O2O必须换个姿势求生存,以商户运营撬动用户运营(或简称为"以B端带C端&

dede淘宝客跳转

首先,给模型添加一个新字段用来保存淘宝客链接 然后模板内容页中用<a href="{dede:field name='phpurl'/}/url.php?id={dede:field name='id'/}" target="_blank">淘宝客链接</a>最后最重要的是 url.php了,下载后放置到plus文件夹内,需根据自己添加的 淘宝客链接字段名称更改文件中的查询 最后效果图如图 URL.PHP 以下为内容-------------

python 自动生成淘宝客链接

class tbk: __login_cookie = "" __fetch_taobaoke_url = "" def __init__(self): self.__login_cookie = self.read_file("../cookie.txt") #cookie 文件 self.__fetch_taobaoke_url = "http://pub.alimama.com/common/code/getAuctionCode

thinkphp接收阿里淘宝客数据

坑在于淘宝客api返回的数据对象是SimpleXMLElement Object类型,不转为php的json array类型数据直接扔到thinkphp循环输出中会达不到要的效果,奇奇怪怪的数组,一度怀疑是html循环赋值有问题,最后终于怀疑到数据格式. 得到淘宝客的数据口,轻松将SimpleXMLElement Object转为json 对象一切正常了. date_default_timezone_set('Asia/Shanghai'); $c = new TopClient; $c->ap