Skip to content

Instantly share code, notes, and snippets.

@atton
Last active December 1, 2017 04:31
result = Amazon::Ecs.send_request({response_group: 'Images,ItemAttributes,Large',
operation: 'ItemSearch',
browse_node: '2293143051',
minimum_price: 0,
maximum_price: 0,
search_index: 'Books'
marketplace: 'jp'})
# return items
API_END_POINT = 'https://app.rakuten.co.jp/services/api/Kobo/EbookSearch/20170426'
APPLICATION_ID = 'hoge'
AFFILIATE_ID = 'fuga'
ElementInformations = ['largeImageUrl', 'title', 'affiliateUrl', 'itemPrice', 'publisherName']
DefaultOpts = {affiliateId: AFFILIATE_ID,
applicationId: APPLICATION_ID,
elements: ElementInformations.join(','),
formatVersion: 2,
field: 0,
hits: 30,
koboGenreId: 101,
language: 'JA',
salesType: 0,
sort: '+itemPrice'}
def post hash
uri = URI.parse(API_END_POINT)
https = Net::HTTP.new(uri.host, 443)
https.use_ssl = true
path = uri.path
path += '?'
path += URI.encode_www_form(DefaultOpts.merge(hash))
request = Net::HTTP::Post.new(path)
https.request(request)
end
post(1) # request 1 page
require 'amazon/ecs'
Amazon::Ecs.configure do |options|
options[:subscription_id] = options[:AWS_access_key_id] = 'hoge'
options[:AWS_secret_key] = 'fuga'
options[:associate_tag] = 'piyo'
end
result = Amazon::Ecs.send_request({response_group: 'Images,ItemAttributes,Large',
operation: 'ItemSearch',
browse_node: '2293143051',
minimum_price: 0,
maximum_price: 0,
search_index: 'Books'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment