Ruby 打开https时的EOR

Ruby 打开https时的EOR,ruby,https,open-uri,Ruby,Https,Open Uri,我一直在尝试使用facebook图形api,不过ruby在打开api url时会提高EOFError(https://graph.facebook.com/.....) 我正在使用Ruby 1.8.6和Rails 2.2.2。 代码如下: require 'uri' require 'https' access_token = open("https://graph.facebook.com/oauth/access_token?client_id=app_id&client_secr

我一直在尝试使用facebook图形api,不过ruby在打开api url时会提高EOFError(https://graph.facebook.com/.....) 我正在使用Ruby 1.8.6和Rails 2.2.2。 代码如下:

require 'uri'
require 'https'

access_token = open("https://graph.facebook.com/oauth/access_token?client_id=app_id&client_secret=app_secret&grant_type=client_credentials"){|f|
   f.read
}
出现以下错误:

end of file reached

/Users/user/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/net/protocol.rb:133:in `sysread'
/Users/user/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/net/protocol.rb:133:in `rbuf_fill'
/Users/user/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/timeout.rb:62:in `timeout'
/Users/user/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/timeout.rb:93:in `timeout'
/Users/user/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/net/protocol.rb:132:in `rbuf_fill'
/Users/user/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/net/protocol.rb:116:in `readuntil'
/Users/user/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/net/protocol.rb:126:in `readline'
/Users/user/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/net/http.rb:2022:in `read_status_line'
/Users/user/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/net/http.rb:2011:in `read_new'
/Users/user/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/net/http.rb:1050:in `request'
/Users/user/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/open-uri.rb:248:in `open_http'
/Users/user/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/net/http.rb:543:in `start'
/Users/user/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/open-uri.rb:242:in `open_http'
/Users/user/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/open-uri.rb:616:in `buffer_open'
/Users/user/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/open-uri.rb:164:in `open_loop'
/Users/user/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/open-uri.rb:162:in `catch'
/Users/user/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/open-uri.rb:162:in `open_loop'
/Users/user/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/open-uri.rb:132:in `open_uri'
/Users/user/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/open-uri.rb:518:in `open'
/Users/user/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/open-uri.rb:30:in `open'
app/models/news_release.rb:75:in `post_to_facebook_wall'
我彻底地在谷歌上搜索了这个错误,并尝试了httpparty、mechanism、fb_图和考拉。 然而,这些都会引起同样的错误。 ruby-1.8.6或OpenURI似乎有一个bug,但我不想升级ruby

有什么想法吗?
提前感谢。

ssl似乎失败了,因为您没有填写参数。试着这样做:

require 'open-uri'

app_id = 'fill_me_out'
app_secret = 'fill_me_out_too'
url = "https://graph.facebook.com/oauth/access_token?client_id=#{app_id}&client_secret=#{app_secret}&grant_type=client_credentials"
access_token = open(url).read
谢谢你的回复:-)事实上,问题是我的插件。。。我在插件中重写了HTTP类,这会导致错误。在注释掉这些行之后,一切都很好。