Class: Tbkapi::Taobaoke
- Inherits:
-
Object
- Object
- Tbkapi::Taobaoke
- Includes:
- Tbkapi
- Defined in:
- lib/tbkapi/api_taobaoke.rb
Constant Summary
Constants included from Tbkapi
Instance Method Summary collapse
- #build_query(hash) ⇒ Object
- #taobao_itemcats_get(parent_cid, cids, api_key, secret) ⇒ Object
- #taobao_ju_items_search(q, pid, api_key, secret) ⇒ Object
- #taobao_tbk_content_get(adzone_id, api_key, secret, type, before_time, count, cid, content_set) ⇒ Object
- #taobao_tbk_dg_item_coupon_get(q, adzone_id, api_key, secret, page_no = 1, page_size = 20) ⇒ Object
-
#taobao_tbk_dg_material_optional(keyword, cat, sort, is_tmall, is_overseas, has_coupon, start_dsr, start_tk_rate, end_tk_rate, start_price, end_price, material_id, api_key, secret, adzone_id, page_no = 1, page_size = 20) ⇒ Object
只有 start_price 与 end_price 有一个不为nil的时候价格筛选就生效 npx_level include_pay_rate_30 include_good_rate include_rfd_rate 测试没什么效果 start_dsr 0 - 50000.
- #taobao_tbk_dg_optimus_material(adzone_id, api_key, secret, material_id = 4071, page_no = 1, page_size = 20) ⇒ Object
- #taobao_tbk_item_convert(adzone_id, api_key, secret, item_id) ⇒ Object
- #taobao_tbk_item_coupon_get(q, pid, api_key, secret) ⇒ Object
- #taobao_tbk_item_get(keyword, api_key, secret, page_no = 1, page_size = 20) ⇒ Object
-
#taobao_tbk_item_get_new(keyword, cat, sort, is_tmall, start_price, end_price, api_key, secret, page_no = 1, page_size = 20) ⇒ Object
只有 start_price 与 end_price 同时不为nil的时候价格筛选才生效.
- #taobao_tbk_item_info_get(ids, api_key, secret) ⇒ Object
- #taobao_tbk_item_recommend_get(num_iid, api_key, secret, page_size = 20) ⇒ Object
- #taobao_tbk_item_word_get(item_id, count, adzone_id, api_key, secret) ⇒ Object
- #taobao_tbk_items_detail_get(ids, api_key, secret) ⇒ Object
- #taobao_tbk_shop_convert(adzone_id, api_key, secret, shop_id) ⇒ Object
- #taobao_tbk_shop_get(q, api_key, secret) ⇒ Object
- #taobao_tbk_shop_get_new(q, api_key, secret, is_tmall = false, start_credit = 1, end_credit = 20, page_no = 1, page_size = 20) ⇒ Object
- #taobao_tbk_spread_get(url, api_key, secret) ⇒ Object
- #taobao_tbk_tpwd_create(url, text, api_key, secret, logo = nil, user_id = nil) ⇒ Object
- #taobao_tbk_uatm_favorites_get(api_key, secret, page_no = 1, page_size = 20) ⇒ Object
- #taobao_tbk_uatm_favorites_item_get(favorites_id, adzone_id, unid, api_key, secret, platform = 2, page_no = 1, page_size = 20) ⇒ Object
- #taobao_wireless_share_tpwd_create(url, text, api_key, secret, logo = nil, user_id = nil) ⇒ Object
- #taobao_wireless_share_tpwd_query(password_content, api_key, secret) ⇒ Object
Methods included from Tbkapi
#action_params, #get_sign, #system_params
Instance Method Details
#build_query(hash) ⇒ Object
6 7 8 |
# File 'lib/tbkapi/api_taobaoke.rb', line 6 def build_query(hash) hash.map{|key, value| "#{key}=#{value}"}.join('&') end |
#taobao_itemcats_get(parent_cid, cids, api_key, secret) ⇒ Object
273 274 275 276 277 278 279 280 281 282 |
# File 'lib/tbkapi/api_taobaoke.rb', line 273 def taobao_itemcats_get(parent_cid, cids, api_key, secret) action_params = { parent_cid: parent_cid, fields: "cid,parent_cid,name,is_parent", cids: cids } params = system_params("taobao.itemcats.get", api_key).merge(action_params) my_sign = get_sign(params, secret).upcase Net::HTTP.get(URI(TBURI + '?' + URI.encode(build_query(params.merge({sign: my_sign}))))) end |
#taobao_ju_items_search(q, pid, api_key, secret) ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/tbkapi/api_taobaoke.rb', line 137 def taobao_ju_items_search(q, pid, api_key, secret) action_params ={ param_top_item_query: { pid: pid, word: q }.to_json } params = system_params("taobao.ju.items.search", api_key).merge(action_params) my_sign = get_sign(params, secret).upcase Net::HTTP.get(URI(TBURI + '?' + URI.encode(build_query(params.merge({sign: my_sign}))))) end |
#taobao_tbk_content_get(adzone_id, api_key, secret, type, before_time, count, cid, content_set) ⇒ Object
236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
# File 'lib/tbkapi/api_taobaoke.rb', line 236 def taobao_tbk_content_get(adzone_id, api_key, secret, type, before_time, count, cid, content_set) action_params = { adzone_id: adzone_id } action_params[:type] = type if type && type > 0 action_params[:before_timestamp] = before_time if before_time && before_time > 0 action_params[:count] = count if count && count > 0 action_params[:cid] = cid if cid && cid > 0 action_params[:content_set] = content_set if content_set && content_set > 0 params = system_params("taobao.tbk.content.get", api_key).merge(action_params) my_sign = get_sign(params, secret).upcase Net::HTTP.get(URI(TBURI + '?' + URI.encode(build_query(params.merge({sign: my_sign}))))) end |
#taobao_tbk_dg_item_coupon_get(q, adzone_id, api_key, secret, page_no = 1, page_size = 20) ⇒ Object
149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/tbkapi/api_taobaoke.rb', line 149 def taobao_tbk_dg_item_coupon_get(q, adzone_id, api_key, secret, page_no = 1, page_size = 20) action_params = { adzone_id: adzone_id, page_size: page_size, page_no: page_no, q: q } params = system_params("taobao.tbk.dg.item.coupon.get", api_key).merge(action_params) my_sign = get_sign(params, secret).upcase Net::HTTP.get(URI(TBURI + '?' + URI.encode(build_query(params.merge({sign: my_sign}))))) end |
#taobao_tbk_dg_material_optional(keyword, cat, sort, is_tmall, is_overseas, has_coupon, start_dsr, start_tk_rate, end_tk_rate, start_price, end_price, material_id, api_key, secret, adzone_id, page_no = 1, page_size = 20) ⇒ Object
只有 start_price 与 end_price 有一个不为nil的时候价格筛选就生效npx_level include_pay_rate_30 include_good_rate include_rfd_rate 测试没什么效果start_dsr 0 - 50000
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/tbkapi/api_taobaoke.rb', line 201 def taobao_tbk_dg_material_optional(keyword, cat, sort, is_tmall, is_overseas, has_coupon, start_dsr, start_tk_rate, end_tk_rate, start_price, end_price, material_id, api_key, secret, adzone_id, page_no = 1, page_size = 20) action_params = { adzone_id: adzone_id, material_id: material_id, page_no: page_no, page_size: page_size } action_params[:q] = keyword unless keyword.nil? action_params[:cat] = cat unless cat.nil? action_params[:sort] = sort unless sort.nil? action_params[:is_tmall] = is_tmall unless is_tmall.nil? action_params[:is_overseas] = is_overseas unless is_overseas.nil? action_params[:has_coupon] = has_coupon unless has_coupon.nil? action_params[:start_dsr] = start_dsr unless start_dsr.nil? action_params[:start_tk_rate] = start_tk_rate unless start_tk_rate.nil? action_params[:end_tk_rate] = end_tk_rate unless end_tk_rate.nil? action_params[:start_price] = start_price unless start_price.nil? action_params[:end_price] = end_price unless end_price.nil? params = system_params("taobao.tbk.dg.material.optional.upgrade",api_key).merge(action_params) my_sign = get_sign(params, secret).upcase Net::HTTP.get(URI(URI.encode((TBURI + '?' + build_query(params.merge({sign: my_sign})))))) end |
#taobao_tbk_dg_optimus_material(adzone_id, api_key, secret, material_id = 4071, page_no = 1, page_size = 20) ⇒ Object
224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/tbkapi/api_taobaoke.rb', line 224 def taobao_tbk_dg_optimus_material(adzone_id, api_key, secret, material_id = 4071, page_no = 1, page_size = 20) action_params = { adzone_id: adzone_id, material_id: material_id, page_no: page_no, page_size: page_size } params = system_params("taobao.tbk.dg.optimus.material", api_key).merge(action_params) my_sign = get_sign(params, secret).upcase Net::HTTP.get(URI(TBURI + '?' + URI.encode(build_query(params.merge({sign: my_sign}))))) end |
#taobao_tbk_item_convert(adzone_id, api_key, secret, item_id) ⇒ Object
262 263 264 265 266 267 268 269 270 271 |
# File 'lib/tbkapi/api_taobaoke.rb', line 262 def taobao_tbk_item_convert(adzone_id, api_key, secret, item_id) action_params = { adzone_id: adzone_id, fields: "num_iid,click_url", num_iids: item_id } params = system_params("taobao.tbk.item.convert", api_key).merge(action_params) my_sign = get_sign(params, secret).upcase Net::HTTP.get(URI(TBURI + '?' + URI.encode(build_query(params.merge({sign: my_sign}))))) end |
#taobao_tbk_item_coupon_get(q, pid, api_key, secret) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/tbkapi/api_taobaoke.rb', line 96 def taobao_tbk_item_coupon_get(q, pid, api_key, secret) action_params = { q: q, pid: pid } params = system_params("taobao.tbk.item.coupon.get",api_key).merge(action_params) my_sign = get_sign(params, secret).upcase if q.include?('//') url = URI(TBURI + '?' + URI.escape(build_query(params.merge({sign: my_sign})),'/:?')) else url = URI(TBURI + '?' + URI.encode(build_query(params.merge({sign: my_sign})))) end Net::HTTP.get(url) end |
#taobao_tbk_item_get(keyword, api_key, secret, page_no = 1, page_size = 20) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/tbkapi/api_taobaoke.rb', line 54 def taobao_tbk_item_get(keyword, api_key, secret, page_no = 1, page_size = 20) action_params = { fields: "num_iid,title,pict_url,small_images,reserve_price,zk_final_price,user_type,provcity,item_url,seller_id,volume,nick", q: keyword, page_no: page_no, page_size: page_size } params = system_params("taobao.tbk.item.get",api_key).merge(action_params) my_sign = get_sign(params, secret).upcase Net::HTTP.get(URI(URI.encode((TBURI + '?' + build_query(params.merge({sign: my_sign})))))) end |
#taobao_tbk_item_get_new(keyword, cat, sort, is_tmall, start_price, end_price, api_key, secret, page_no = 1, page_size = 20) ⇒ Object
只有 start_price 与 end_price 同时不为nil的时候价格筛选才生效
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/tbkapi/api_taobaoke.rb', line 37 def taobao_tbk_item_get_new(keyword, cat, sort, is_tmall, start_price, end_price, api_key, secret, page_no = 1, page_size = 20) action_params = { fields: "num_iid,title,pict_url,small_images,reserve_price,zk_final_price,user_type,provcity,item_url,seller_id,volume,nick", page_no: page_no, page_size: page_size } action_params[:q] = keyword unless keyword.nil? action_params[:cat] = cat unless cat.nil? action_params[:sort] = sort unless sort.nil? action_params[:is_tmall] = is_tmall unless is_tmall.nil? action_params[:start_price] = start_price unless start_price.nil? action_params[:end_price] = end_price unless end_price.nil? params = system_params("taobao.tbk.item.get",api_key).merge(action_params) my_sign = get_sign(params, secret).upcase Net::HTTP.get(URI(URI.encode((TBURI + '?' + build_query(params.merge({sign: my_sign})))))) end |
#taobao_tbk_item_info_get(ids, api_key, secret) ⇒ Object
86 87 88 89 90 91 92 93 94 |
# File 'lib/tbkapi/api_taobaoke.rb', line 86 def taobao_tbk_item_info_get(ids, api_key, secret) action_params = { fields: "num_iid,title,pict_url,small_images,reserve_price,zk_final_price,user_type,provcity,nick,seller_id,volume,cat_leaf_name,cat_name", num_iids: ids.join(",") } params = system_params("taobao.tbk.item.info.get",api_key).merge(action_params) my_sign = get_sign(params, secret).upcase Net::HTTP.get(URI(TBURI + '?' + build_query(params.merge({sign: my_sign})))) end |
#taobao_tbk_item_recommend_get(num_iid, api_key, secret, page_size = 20) ⇒ Object
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/tbkapi/api_taobaoke.rb', line 66 def taobao_tbk_item_recommend_get(num_iid, api_key, secret, page_size = 20) action_params = { fields: "num_iid,title,pict_url,small_images,reserve_price,zk_final_price,user_type,provcity,item_url", num_iid: num_iid, count: page_size } params = system_params("taobao.tbk.item.recommend.get",api_key).merge(action_params) my_sign = get_sign(params, secret).upcase Net::HTTP.get(URI(URI.encode((TBURI + '?' + build_query(params.merge({sign: my_sign})))))) end |
#taobao_tbk_item_word_get(item_id, count, adzone_id, api_key, secret) ⇒ Object
284 285 286 287 288 289 290 291 292 293 |
# File 'lib/tbkapi/api_taobaoke.rb', line 284 def taobao_tbk_item_word_get(item_id, count, adzone_id, api_key, secret) action_params = { item_id: item_id, adzone_id: adzone_id, count: count } params = system_params("taobao.tbk.item.word.get", api_key).merge(action_params) my_sign = get_sign(params, secret).upcase Net::HTTP.get(URI(TBURI + '?' + URI.encode(build_query(params.merge({sign: my_sign}))))) end |
#taobao_tbk_items_detail_get(ids, api_key, secret) ⇒ Object
77 78 79 80 81 82 83 84 85 |
# File 'lib/tbkapi/api_taobaoke.rb', line 77 def taobao_tbk_items_detail_get(ids, api_key, secret) action_params = { fields: "num_iid,seller_id,nick,title,volume,pic_url,item_url,shop_url,click_url,price,discount_price", num_iids: ids.join(",") } params = system_params("taobao.tbk.items.detail.get",api_key).merge(action_params) my_sign = get_sign(params, secret).upcase Net::HTTP.get(URI(TBURI + '?' + build_query(params.merge({sign: my_sign})))) end |
#taobao_tbk_shop_convert(adzone_id, api_key, secret, shop_id) ⇒ Object
251 252 253 254 255 256 257 258 259 260 |
# File 'lib/tbkapi/api_taobaoke.rb', line 251 def taobao_tbk_shop_convert(adzone_id, api_key, secret, shop_id) action_params = { adzone_id: adzone_id, fields: "user_id,click_url", user_ids: shop_id } params = system_params("taobao.tbk.shop.convert", api_key).merge(action_params) my_sign = get_sign(params, secret).upcase Net::HTTP.get(URI(TBURI + '?' + URI.encode(build_query(params.merge({sign: my_sign}))))) end |
#taobao_tbk_shop_get(q, api_key, secret) ⇒ Object
111 112 113 114 115 116 117 118 119 |
# File 'lib/tbkapi/api_taobaoke.rb', line 111 def taobao_tbk_shop_get(q, api_key, secret) action_params ={ fields: "user_id,shop_title,shop_type,seller_nick,pict_url,shop_url", q: q } params = system_params("taobao.tbk.shop.get",api_key).merge(action_params) my_sign = get_sign(params, secret).upcase Net::HTTP.get(URI(TBURI + '?' + URI.encode(build_query(params.merge({sign: my_sign}))))) end |
#taobao_tbk_shop_get_new(q, api_key, secret, is_tmall = false, start_credit = 1, end_credit = 20, page_no = 1, page_size = 20) ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/tbkapi/api_taobaoke.rb', line 121 def taobao_tbk_shop_get_new(q, api_key, secret, is_tmall = false, start_credit = 1, end_credit = 20, page_no = 1, page_size= 20) action_params ={ fields: "user_id,shop_title,shop_type,seller_nick,pict_url,shop_url", q: q, is_tmall: is_tmall, start_credit: start_credit, end_credit: end_credit, page_no: page_no, page_size: page_size, sort: "total_auction_des" } params = system_params("taobao.tbk.shop.get",api_key).merge(action_params) my_sign = get_sign(params, secret).upcase Net::HTTP.get(URI(TBURI + '?' + URI.encode(build_query(params.merge({sign: my_sign}))))) end |
#taobao_tbk_spread_get(url, api_key, secret) ⇒ Object
295 296 297 298 299 300 301 302 |
# File 'lib/tbkapi/api_taobaoke.rb', line 295 def taobao_tbk_spread_get(url, api_key, secret) action_params = { requests: [{url: url}].to_json } params = system_params("taobao.tbk.spread.get", api_key).merge(action_params) my_sign = get_sign(params, secret).upcase Net::HTTP.get(URI(TBURI + '?' + URI.encode(build_query(params.merge({sign: my_sign}))))) end |
#taobao_tbk_tpwd_create(url, text, api_key, secret, logo = nil, user_id = nil) ⇒ Object
161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/tbkapi/api_taobaoke.rb', line 161 def taobao_tbk_tpwd_create(url, text, api_key, secret, logo = nil, user_id = nil) action_params = { text: text, url: url } action_params[:logo] = logo if logo action_params[:user_id] = user_id if user_id params = system_params("taobao.tbk.tpwd.create", api_key).merge(action_params) my_sign = get_sign(params, secret).upcase params.delete(:url) Net::HTTP.get(URI(TBURI + '?' + URI.encode(build_query(params.merge({sign: my_sign}))) + "&url=" + URI.encode_www_form_component(url))) end |
#taobao_tbk_uatm_favorites_get(api_key, secret, page_no = 1, page_size = 20) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/tbkapi/api_taobaoke.rb', line 10 def taobao_tbk_uatm_favorites_get(api_key, secret, page_no = 1, page_size = 20) action_params = { fields: "favorites_title,favorites_id,type", page_no: page_no, page_size: page_size } params = system_params("taobao.tbk.uatm.favorites.get",api_key).merge(action_params) my_sign = get_sign(params, secret).upcase Net::HTTP.get(URI(TBURI + '?' + build_query(params.merge({sign: my_sign})))) end |
#taobao_tbk_uatm_favorites_item_get(favorites_id, adzone_id, unid, api_key, secret, platform = 2, page_no = 1, page_size = 20) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/tbkapi/api_taobaoke.rb', line 21 def taobao_tbk_uatm_favorites_item_get(favorites_id, adzone_id, unid, api_key, secret, platform = 2,page_no = 1, page_size = 20) action_params = { adzone_id: adzone_id, unid: unid, favorites_id: favorites_id, fields: "num_iid,title,pict_url,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,click_url,status,category,coupon_click_url,coupon_end_time,coupon_info,coupon_start_time,coupon_total_count,coupon_remain_count", platform: platform, page_no: page_no, page_size: page_size } params = system_params("taobao.tbk.uatm.favorites.item.get",api_key).merge(action_params) my_sign = get_sign(params, secret).upcase Net::HTTP.get(URI(TBURI + '?' + build_query(params.merge({sign: my_sign})))) end |
#taobao_wireless_share_tpwd_create(url, text, api_key, secret, logo = nil, user_id = nil) ⇒ Object
174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/tbkapi/api_taobaoke.rb', line 174 def taobao_wireless_share_tpwd_create(url, text, api_key, secret, logo = nil, user_id = nil) data = { text: text, url: url } data[:logo] = logo if logo data[:user_id] = user_id if user_id action_params = { tpwd_param: data.to_json } params = system_params("taobao.wireless.share.tpwd.create", api_key).merge(action_params) my_sign = get_sign(params, secret).upcase Net::HTTP.get(URI(TBURI + '?' + URI.encode(build_query(params.merge({sign: my_sign}))))) end |
#taobao_wireless_share_tpwd_query(password_content, api_key, secret) ⇒ Object
189 190 191 192 193 194 195 196 |
# File 'lib/tbkapi/api_taobaoke.rb', line 189 def taobao_wireless_share_tpwd_query(password_content, api_key, secret) action_params = { password_content: password_content } params = system_params("taobao.wireless.share.tpwd.query", api_key).merge(action_params) my_sign = get_sign(params, secret).upcase Net::HTTP.get(URI(TBURI + '?' + URI.encode(build_query(params.merge({sign: my_sign}))))) end |