lib/tbkapi/api_taobaoke.rb in tbkapi-0.0.2 vs lib/tbkapi/api_taobaoke.rb in tbkapi-0.0.3
- old
+ new
@@ -1,19 +1,23 @@
module Tbkapi
class Taobaoke
include Tbkapi
+ def build_query(hash)
+ hash.map{|key, value| "#{key}=#{value}"}.join('&')
+ end
+
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
- HTTParty.get(TBURI, query: params.merge({sign: my_sign}))
+ Net::HTTP.get(URI(TBURI + '?' + build_query(params.merge({sign: my_sign}))))
end
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,
@@ -24,11 +28,11 @@
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
- HTTParty.get(TBURI, query: params.merge({sign: my_sign}))
+ Net::HTTP.get(URI(TBURI + '?' + build_query(params.merge({sign: my_sign}))))
end
def taobao_tbk_item_get(keyword, api_key, secret, page_size = 20)
@@ -37,20 +41,20 @@
q: keyword,
page_size: page_size
}
params = system_params("taobao.tbk.item.get",api_key).merge(action_params)
my_sign = get_sign(params, secret).upcase
- HTTParty.get(TBURI, query: params.merge({sign: my_sign}))
+ Net::HTTP.get(URI(TBURI + '?' + build_query(params.merge({sign: my_sign}))))
end
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
- HTTParty.get(TBURI, query: params.merge({sign: my_sign}))
+ Net::HTTP.get(URI(TBURI + '?' + build_query(params.merge({sign: my_sign}))))
end
end
end