我无法将 curl 转换为 ruby 脚本。基本上我正在尝试使用 parse.com RESTful api。这是卷曲
curl -X POST \
-H "X-Parse-Application-Id: XXX" \
-H "X-Parse-REST-API-Key: YYY" \
-H "Content-Type: application/json" \
-d '{
"channels": [
"Giants",
"Mets"
],
"data": {
"alert": "test message"
}
}' \
https://api.parse.com/1/push
这就是我一直在尝试做的(使用 HttParty)
puts "hello world"
require 'httparty'
require 'json'
class Parse
include HTTParty
base_uri "api.parse.com:443"
headers "X-Parse-Application-Id" => "XXX", "X-Parse-REST-API-Key" => "YYY", "Content-Type" => "application/json"
end
option = {:channels => "Giants", :data => {:alert => "un mensaje de mierda"}}
puts Parse.post("/1/push", body: option.to_json)
)
我收到错误代码 107 说无效的 json。任何建议将不胜感激。