开发者

How do I send in a REST request (to use an API)?

I'm writing a small web app for myself in Rails and I want it to use Last.fm's API. I'm incredibly new to web development in general, so I'开发者_开发技巧m not sure where to even begin.

http://www.last.fm/api/rest

I'm not asking for a step-by-step tutorial or anything like that, but a nudge in the right direction would be awesome. Or even just a little example code.


Installing HTTParty will get you started, you might also want to make some calls to the API from the command line using cURL just to understand how it works. Just type cURL and the restful URL on the commandline:

prompt> curl http://www.whatever.com/resource for a get

prompt> curl -d '{ "arg" : "value" }' http://www.whatever.com/ for posts etc.

Often understanding what comes back in each of the calls will help you structure your app. Have fun.


Dupe of this 748614

Simply speaking - use the HTTParty gem, it does literally everything for you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜