我有以下有效的 Curl 命令:
curl -H "Authorization:GoogleLogin auth=xxx" http://www.google.com/reader/api/0/user-info
我尝试通过 BubbleWrap HTTP 中的 get
来执行此操作:
HTTP.get("http://www.google.com/reader/api/0/user-info",
{
:headers => { "Authorization:GoogleLogin auth" => "xxx"}
}) do |response|
puts response
puts response.body.to_str
end
但是我收到了 401 返回,所以也许我没有正确设置 header ?
最佳答案
header 名称应为 Authorization
,值为 GoogleLogin auth=xxx
。按照您的操作方式,它是 Authorization:GoogleLogin auth
的 header 名称,值为 xxx
。试试这个:
:headers => {"Authorization" => "GoogleLogin auth=xxx"}
关于ruby - 使用气泡膜 : How to formulate get with custom headers?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14176770/