Skip to content

Instantly share code, notes, and snippets.

@alexyoung
Created March 25, 2009 10:03
Show Gist options
  • Save alexyoung/85400 to your computer and use it in GitHub Desktop.
Save alexyoung/85400 to your computer and use it in GitHub Desktop.
require 'net/http'
require 'uri'
data = '[email protected]&password=your_password'
url = URI.parse('http://helipadapp.com/authenticate')
headers = {
'Content-Type'=> 'application/x-www-form-urlencoded'
}
http = Net::HTTP.new(url.host)
response, data = http.post(url.path, data, headers)
puts '*** HTTP Response ***'
response.each { |key, value| puts "#{key}: #{value}"}
puts
if response['location'].match 'login'
puts "STATUS: Login unsuccessful"
else
puts "STATUS: Logged in"
puts
# Try to fetch a document
cookie = response.response['set-cookie']
headers['Cookie'] = cookie
url = URI.parse 'http://helipadapp.com/document/new'
http = Net::HTTP.new(url.host)
response = http.get2(url.path, headers)
puts '*** HTTP Response ***'
response.each { |key, value| puts "#{key}: #{value}"}
puts ''
if response.body.match /id="Preview"/
puts 'Create document page fetched successfully'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment