如何发送 REST 请求(以使用 API)?

发布于 2024-09-10 16:46:43 字数 243 浏览 1 评论 0原文

我正在 Rails 中为自己编写一个小型 Web 应用程序,我希望它使用 Last.fm 的 API。总的来说,我对网络开发非常陌生,所以我不知道从哪里开始。

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

我不是要求分步教程或类似的东西,但朝着正确的方向轻推会很棒。或者甚至只是一些示例代码。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

流殇 2024-09-17 16:46:43

安装 HTTParty 将帮助您入门,您可能还想使用 cURL 从命令行对 API 进行一些调用,以了解它的工作原理。只需在命令行中输入 cURL 和 Restful URL:

prompt>卷曲 http://www.whatever.com/resource 获取

提示> curl -d '{ "arg" : "value" }' http://www.whatever.com/ 用于帖子等。

通常了解每个调用中返回的内容将帮助您构建应用程序。玩得开心。

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.

东北女汉子 2024-09-17 16:46:43

复制这个748614

简单来说 - 使用 HTTParty gem,它实际上可以为您做所有事情。

Dupe of this 748614

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文