rakuten-ws / rws-ruby-sdk Goto Github PK
View Code? Open in Web Editor NEWRuby Client for Rakuten Web Service
Home Page: http://webservice.rakuten.co.jp/
License: MIT License
Ruby Client for Rakuten Web Service
Home Page: http://webservice.rakuten.co.jp/
License: MIT License
bundlerを使わない場合、require 'uri'しないと動かない場合があるので直せないでしょうか。
bundlerを使わずにgem install した環境で以下のサンプルを実行させようとすると以下のエラーがでました。
require'rakuten_web_service'
RakutenWebService.configuration do |c|
c.application_id = 'ID'
c.affiliate_id ='ID'
end
items = RakutenWebService::Ichiba::Item.search(:keyword => 'Ruby') # This returns Enamerable object
ターミナルで
$ ruby 2test_rakuten.rb
と実行すると以下のエラーがでました。
/Users/yuki/gem/gems/rakuten_web_service-0.6.2/lib/rakuten_web_service/client.rb:18:in `initialize': uninitialized constant RakutenWebService::Client::URI (NameError)
from /Users/username/gem/gems/rakuten_web_service-0.6.2/lib/rakuten_web_service/search_result.rb:8:in `new'
from /Users/username/gem/gems/rakuten_web_service-0.6.2/lib/rakuten_web_service/search_result.rb:8:in `initialize'
from /Users/username/gem/gems/rakuten_web_service-0.6.2/lib/rakuten_web_service/resource.rb:29:in `new'
from /Users/username/gem/gems/rakuten_web_service-0.6.2/lib/rakuten_web_service/resource.rb:29:in `search'
from 2test_rakuten.rb:8:in `<main>'
ライブラリのソースを見て調べてみて
require 'rakuten_web_service'
require 'uri'
と記入するとエラーは解消できました。
ソースを見ないとわからなかったので、解消されると嬉しいです。
Hello!
Using Rakuten LinkShare portal. There is the "Product LinkFinder" function to search for products and get product list with product title, description, photo, price.
Is it possible to get product list with rws-ruby-sdk?
Thanks in advance.
rws-ruby-sdkをForkし、ローカルリポジトリにcloneした。その後、rws-ruby-sdk/examples/ichiba_item_search.rbをターミナル上で実行しようとすると、
.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rakuten_web_service-0.6.2/lib/rakuten_web_service/client.rb:18:in `initialize': uninitialized constant RakutenWebService::Client::URI (NameError)
とエラーが出る。
application_idには楽天ウェブサービスで新規アプリ登録をした際に発行された値を与えている。
_実行環境_
Ubuntu 14.04, ruby 2.2.0
−−−−−−−−
rws-ruby-sdk/examples/ichiba_item_search.rb
rws-ruby-sdk/lib/rakuten_web_service/client.rb
の行頭に
require 'uri'
を追加した。
_ichiba_item_search.rb_
修正前
encoding: utf-8
require 'rakuten_web_service'
修正後
encoding: utf-8
require 'rakuten_web_service'
require 'uri'
_client.rb_
修正前
require 'faraday'
require 'faraday_middleware'
require 'rakuten_web_service/response'
修正後
require 'faraday'
require 'faraday_middleware'
require 'rakuten_web_service/response'
require 'uri'
https://github.com/rakuten-ws/rws-ruby-sdk#市場商品ランキング の例に
RakutenWebService::Ichiba::Genre[100316].ranking # "水・ソフトドリンク" ジャンルのTOP 30
という記述があり、それを取得しようとしたところ、以下のエラーが出力された。
ichiba_ranking.rb:11:in
<main>': undefined method
ranking' for nil:NilClass (NoMethodError)
$ gem install rakuten_web_service
でrws-ruby-sdkをインストールした。
$ ruby ichiba_ranking.rb [my_application_id]
# encoding: utf-8
require 'rakuten_web_service'
application_id = ARGV.shift
RakutenWebService.configuration do |c|
c.application_id = application_id
end
rank = RakutenWebService::Ichiba::Genre[100316].ranking
rank.first(10).each do |item|
puts "#{item['itemName']}, #{item['itemPrice']} yen"
end
Rubyのバージョン: 2.2.2
OS: ubuntu 14.04 LTS
RakutenWebService::Ichiba::Genre[100316].ranking
を
RakutenWebService::Ichiba::Genre.new(100316).ranking
に書き換えたところ結果が表示された。
Similar code found in 1 other location (mass = 20)
I found @kamatama41's branch for supporting GOLA API in his repository! and it looks good to me.
@kamatama41 Do you think you can open a pull request?
サンプルのYOUR_APPLICATION_IDの部分で自分のIDが必要だと言うことがわからなかったので、READMEに書いてあると嬉しいです。
README.mdを見ながらrubyを実際に動かそうとしていました。まず最初のサンプルを実行させました。参照したのは以下の部分です。
https://github.com/rakuten-ws/rws-ruby-sdk#設定
RakutenWebService.configuration do |c|
c.application_id = YOUR_APPLICATION_ID
c.affiliate_id = YOUR_AFFILIATE_ID
end
しかし、最初のサンプルでエラーが出て、そのエラーは以下のものでした。
test_rakuten.rb:8:in `block in <main>': uninitialized constant YOUR_APPLICATION_ID (NameError)
from /Users/yuki/gem/gems/rakuten_web_service-0.6.2/lib/rakuten_web_service/configuration.rb:20:in `call'
from /Users/yuki/gem/gems/rakuten_web_service-0.6.2/lib/rakuten_web_service/configuration.rb:20:in `configuration'
from test_rakuten.rb:7:in `<main>'
エラーを見たところによるとYOUR_APPLICATION_IDが見つからないようでした。調べてみるとアプリケーションIDを取得しないといけないことがわかりました。そこで楽天のweb serviceで登録をしました。
改善点としてIDを取得しないといけない旨を記載しておくこと、また、web serviceの登録リンクを記載しておいた方がわかりやすいと考えました。 (リンクは以下のものです。)
https://webservice.rakuten.co.jp/app/create
そして、IDを取得したあとYOUR_APPLICATION_IDを自分のIDに入れ替えたのですが、シングルクォートで囲むことを忘れていたので、その旨も記載しておくと、分かりやすいと考えます。
実際にすぐに使えるようなexampleのIDも記載してあるサンプルコードがあるとわかりやすいと感じました。
Similar code found in 1 other location (mass = 20)
items = RakutenWebService::Ichiba::Item.search(
keyword: 'Ruby',
sort: "+itemPrice"
)
と入力するとエラーが出ました。
"+itemPrice"をUTF-8にエンコードしても同様の結果でした。
書き方が間違っていますでしょうか。どうぞ宜しくお願いします。
The current latest version 1.8.0 are not able to handle Tag
in an response of Ichiba Item search and doesn't support Tag Search API.
Support RWS::Books::ForeginBook API
これはおそらくtypo 😃
Support RWS::Books::ForeignBook API
ではないでしょうか。
RakutenWebService::Ichiba::Item.search(
keyword: 'apple',
elements: 'itemCode,itemPrice,shopCode,shopName,shopUrl,tagIds'
).all.count
=> 30
RakutenWebService::Ichiba::Item.search(
keyword: 'apple'
).all.count
=> 3000
If set elements, it can get only 30 items by all. How can I get 3000 items with param 'elements'?
elementsを指定するとallメソッドで30件(1ページ分)しか帰って来ませんが、どうしたらelementsを指定しつつ3000件返ってくるようになりますか?
2.1.0 or earlier of ruby has been dropped from supported version of this gem. This means that refinements
can be applies!
It would refine here and here in readability.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.