I came across this: https://github.com/archiloque/rest-client ...and it seems fairly simple and straight forward. But, working with third-party APIs is new to me, so I'm not sure what's important in a library and most of all, which is easiest to use.
我遇到这个:https://github.com/archiloque/rest-client…看起来很简单,很直接。但是,使用第三方api对我来说是全新的,所以我不确定在库中什么是重要的,最重要的是最容易使用的。
Does rest-client
offer any advantage over the standard Net::Http?
rest-client与标准Net::Http相比有什么优势吗?
I also found https://github.com/jnunemaker/httparty, though it doesn't seem to be as well documented as rest-client or, even this one: https://github.com/dbalatero/typhoeus. Are they better than the included standard?
我还发现了https://github.com/jnunemaker/httparty,尽管它似乎没有rest-client或者(甚至是这个:https://github.com/dbalatero/typhoon)那么详细。它们比包含的标准更好吗?
Any thoughts, suggestions?
任何想法,建议吗?
2 个解决方案
#1
3
Net::HTTP is meant to be a low level library for accessing networked resources. The third-party APIs make up for some of the difficulties that you'd otherwise have to handle yourself. To name a few:
Net::HTTP是一个用于访问网络资源的低级库。第三方api弥补了您必须自己处理的一些困难。举几例:
- Handling redirect codes
- 处理重定向代码
- Implementing multipart file uploads
- 实现多部分文件上传
- Storing cookies between requests
- 存储请求之间饼干
- HTTP exception handling
- HTTP异常处理
- Parsing responses (HTML, JSON, etc.)
- 解析响应(HTML、JSON等)
- Managing authentication/SSL on secure sites
- 在安全站点上管理身份验证/SSL
In general, the authors of those libraries have taken extra care to make their API easy to use compared to Net::HTTP.
一般来说,这些库的作者特别注意使其API易于使用,而Net::HTTP。
Also, I've found Mechanize to be a more complete solution for my needs than rest-client. For example, with rest-client you will still have to implement storing cookies between requests and handling redirects on POST requests.
此外,我发现Mechanize比rest-client更能满足我的需求。例如,对于rest-client,您仍然需要实现在请求之间存储cookie并处理POST请求的重定向。
#2
4
You may find useful this short article from Adam Wiggins, initial author of RestClient: http://adam.heroku.com/past/2008/8/8/ruby_libs_for_making_web/
你可以从亚当·威金斯(Adam Wiggins)的这篇短文中找到有用的东西,他是RestClient的最初作者。
I personally am using httparty in my project - this was choice of previous developer, but it works for me pretty well.
我个人在我的项目中使用了httparty——这是以前开发人员的选择,但是对我来说很有效。
#1
3
Net::HTTP is meant to be a low level library for accessing networked resources. The third-party APIs make up for some of the difficulties that you'd otherwise have to handle yourself. To name a few:
Net::HTTP是一个用于访问网络资源的低级库。第三方api弥补了您必须自己处理的一些困难。举几例:
- Handling redirect codes
- 处理重定向代码
- Implementing multipart file uploads
- 实现多部分文件上传
- Storing cookies between requests
- 存储请求之间饼干
- HTTP exception handling
- HTTP异常处理
- Parsing responses (HTML, JSON, etc.)
- 解析响应(HTML、JSON等)
- Managing authentication/SSL on secure sites
- 在安全站点上管理身份验证/SSL
In general, the authors of those libraries have taken extra care to make their API easy to use compared to Net::HTTP.
一般来说,这些库的作者特别注意使其API易于使用,而Net::HTTP。
Also, I've found Mechanize to be a more complete solution for my needs than rest-client. For example, with rest-client you will still have to implement storing cookies between requests and handling redirects on POST requests.
此外,我发现Mechanize比rest-client更能满足我的需求。例如,对于rest-client,您仍然需要实现在请求之间存储cookie并处理POST请求的重定向。
#2
4
You may find useful this short article from Adam Wiggins, initial author of RestClient: http://adam.heroku.com/past/2008/8/8/ruby_libs_for_making_web/
你可以从亚当·威金斯(Adam Wiggins)的这篇短文中找到有用的东西,他是RestClient的最初作者。
I personally am using httparty in my project - this was choice of previous developer, but it works for me pretty well.
我个人在我的项目中使用了httparty——这是以前开发人员的选择,但是对我来说很有效。