简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM