我可以通过以下方式从Oauth2 API获取信息:
token = "Token I get from authenticating my App"
auth = "Bearer " + token
user = HTTParty.get("API Website", :headers => { "Authorization" => auth})
我如何发布在我的应用中生成的API内容?我有一个实例变量:
@contact = {"contact": {"name": "John Doe" }}
我试过了:
token = "Token I get from authenticating my App"
auth = "Bearer " + token
user = HTTParty.get("API Website", :headers => { "Authorization" => auth}, @contact)
无济于事。
答案 0 :(得分:11)
回答了我自己的问题
HTTParty.post("API Website", :headers => { "Authorization" => auth}, :body => "@contact")