Reputation: 31
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?
Upvotes: 1
Views: 1573
Reputation: 4460
You can use the Net:HTTP thats come with rails
For example , in your controller you can use something like this :
uri = URI.parse("https://graph.facebook.com/me/feed")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
# and whatever you want to do with the response var
Remember that you could write this code in a model, or module.
Upvotes: 4
Reputation: 373
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.
Upvotes: 1