我正在尝试使用soundcloud gem,突然间我每次请求都会出错。
例如以下代码:
require 'soundcloud'
client = SoundCloud.new(:client_id => MY_CLIENT_ID)
track_url = 'https://soundcloud.com/sohight/sohight-cheevy-money-is-love-out-now'
track = client.get('/resolve', :url => track_url)
puts track.genre
任何人都知道我为什么会收到此错误?
/Users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty/hash_conversions.rb:33:in `normalize_param': uninitialized constant HTTParty::HashConversions::ERB (NameError)
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty/hash_conversions.rb:15:in `block in to_params'
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty/hash_conversions.rb:15:in `each'
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty/hash_conversions.rb:15:in `map'
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty/hash_conversions.rb:15:in `to_params'
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty/request.rb:148:in `normalize_query'
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty/request.rb:180:in `query_string'
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty/request.rb:70:in `uri'
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty/request.rb:157:in `setup_raw_request'
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty/request.rb:98:in `perform'
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty.rb:521:in `perform_request'
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty.rb:459:in `get'
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/soundcloud-0.3.2/lib/soundcloud/client.rb:27:in `block in get'
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/soundcloud-0.3.2/lib/soundcloud/client.rb:145:in `call'
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/soundcloud-0.3.2/lib/soundcloud/client.rb:145:in `handle_response'
from /Users/angel/.rvm/gems/ruby-2.2.0/gems/soundcloud-0.3.2/lib/soundcloud/client.rb:26:in `get'
from sound.rb:9:in `<main>'
答案 0 :(得分:2)
可能是HTTParty中的错误。
hash_conversions.rb
的第33行:
param << "#{key}=#{ERB::Util.url_encode(value.to_s)}&"
将它放在脚本的顶部,然后重试:
require 'erb'