Thursday, June 3, 2010

Making a http/https post request

Spent an hour to find out how to send a https post request and this is how ..

require 'rubygems'
require 'net/http'
require 'net/https'
require 'uri'
http = Net::HTTP.new('facebook.com', 443)
http.use_ssl = true
path = "/oauth/access_token"
data = 'id=123456'
resp, data = http.post(path, data)
puts resp.inspect
puts data.inspect

Thanks,
Srikanth

4 comments:

Bhatti said...

Thanks buddy.

I lost 2 days to reach at this blog. And really glad that my problem is solved using your code.

Accept my heartiest regards.

Bhatti said...

I lost 2 days in posting some data to an API until I reached this post and bingo! it worked like a charm.

Accept a big thanks and my heartiest regards.

Waqas

heavenlyjohnson said...

Had the same problem for about the last hour. I love the Graph API.

kts said...

THANK YOU!

Solved my problem with oauth2 not posting parameters <3