Created
March 25, 2009 10:03
-
-
Save alexyoung/85400 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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