我正在尝试使用 TradeKing API 让股票价格流工作
https://developers.tradeking.com/documentation/ruby-streaming
或下面复制和粘贴的代码
require 'em-http'
require 'em-http/middleware/oauth'
credentials = {
:consumer_key => "<CONSUMER_KEY>",
:consumer_secret => "<CONSUMER_SECRET>",
:access_token => "<ACCESS_TOKEN>",
:access_token_secret => "<ACCESS_TOKEN_SECRET>"
}
EM.run do
conn = EventMachine::HttpRequest.new('https://stream.tradeking.com/v1/market/quotes.json?symbols=F')
conn.use EventMachine::Middleware::OAuth, credentials
http = conn.get
http.stream { |chunk| puts chunk }
http.errback do
EM.stop
end
trap("INT") { http.close; EM.stop }
trap("TERM") { http.close; EM.stop }
end
获得密钥、秘密和令牌后,我构建了一个简单的 Ruby 应用程序来处理代码,但我收到一个错误,说它无法加载
require 'em-http/middleware/oauth'
如果我禁用它,代码EventMachine::Middleware::OAuth
将不起作用。
这是错误消息:
c:/tools/ruby215/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/
kernel_require.rb:54:in `require': cannot load such file --
simple_oauth (LoadError)
from c:/tools/ruby215/lib/ruby/site_ruby/2.1.0/rubyg
ems/core_ext/kernel_require.rb:54:in `require'
from c:/tools/ruby215/lib/ruby/gems/2.1.0/gems/em-ht
tp-request-1.1.2/lib/em-http/middleware/oauth.rb:1:in `<top
(required)>'
from c:/tools/ruby215/lib/ruby/site_ruby/2.1.0/rubyg
ems/core_ext/kernel_require.rb:54:in `require'
from c:/tools/ruby215/lib/ruby/site_ruby/2.1.0/rubyg
ems/core_ext/kernel_require.rb:54:in `require'
from app.rb:2:in `<main>'
我是事件机器和 em-http gem 的新手。我查看了他们的文档,但找不到有关此错误的信息。有人可以帮我弄清楚为什么文件无法加载吗?