我在网站的网址上使用了Ruby Gem rest-client
。我得到以下错误......
RestClient::Unauthorized (401 Unauthorized):
app/controllers/api/v1/channels_controller.rb:199:in `streaming_link'
帮我修复它。 我的控制器方法如下:
def streaming_link
url = URI.encode("http://eboundservices.com/hash/hash_app.php?code=orientplay")
result = RestClient::Request.new({:user => "hashapp", :password => "PlayFair00",:method => :post, :url => url}).execute
return render :json =>{:success=>true,:result=>result}
end
答案 0 :(得分:2)
我还在与rest-client和401斗争,直到我认识到,这是因为服务所需的摘要认证。 Rest-Client currently did not support digest auth
相反,我切换到httparty,它支持它,并且它有效。也许你的401也一样。
@auth = {:username => 'hashapp', :password => 'PlayFair00'}
options = { :digest_auth => @auth }
response = HTTParty.get('http://eboundservices.com/hash/hash_app.php?code=orientplay', options)