Rails 像curl一样使用Net/Http
卷曲 -F 'access_token=...' \ -F 'message=看看这篇有趣的文章' \ https://graph.facebook.com/me/feed
我用curl写了这个php之前,但我将如何在rails中做到这一点? Rails 中有卷曲之类的东西吗?
curl -F 'access_token=...' \
-F 'message=Check out this funny article' \
https://graph.facebook.com/me/feed
I've written this in curl with php before, but how would I do this in rails? Is there such thing as curl in rails?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 Rails 附带的 Net:HTTP
例如,在您的控制器中您可以使用如下内容:
更新
请记住,您可以在模型或模块中编写此代码。
You can use the Net:HTTP thats come with rails
For example , in your controller you can use something like this :
Update
Remember that you could write this code in a model, or module.
Ruby 中有多个 HTTP 客户端库,您也可以在 Rails 应用程序中使用它们。除了Ruby自己内置的Net:HTTP之外,还有HTTParty(http://httparty.rubyforge.org/)和curb(http://rubygems.org/gems/curb)等库,它是libcurl的包装器。
There are several HTTP client libraries in Ruby, which you could also use from within a Rails app. Besides Ruby's own built-in Net:HTTP, there are libraries such as HTTParty (http://httparty.rubyforge.org/) and curb (http://rubygems.org/gems/curb), which is a wrapper for libcurl.