12

我可以通过以下方式从 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)

无济于事。

4

1 回答 1

13

回答了我自己的问题

HTTParty.post("API Website", :headers => { "Authorization" => auth}, :body => "@contact")
于 2012-09-28T01:13:27.573 回答