Last active
December 1, 2017 04:31
amazon-ecs usage for https://attonblog.blogspot.com/2017/12/okinawa-rb-advent-calendar-2017.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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