Skip to content

Instantly share code, notes, and snippets.

@bricooke
Created September 21, 2008 01:35
Show Gist options
  • Save bricooke/11820 to your computer and use it in GitHub Desktop.
Save bricooke/11820 to your computer and use it in GitHub Desktop.
require 'net/https'
def random_word
alphabet = ('a'..'z').to_a
(1..12).inject("") { |s,x| s << alphabet[rand(alphabet.size)]}
end
class GoogleAuth
def self.login(email, password)
http = Net::HTTP.new('www.google.com', 443)
http.use_ssl = true
path = '/accounts/ClientLogin'
data = \
"accountType=GOOGLE&Email=#{email}" \
"&Passwd=#{password}" \
'&service=writely'
headers = \
{ 'Content-Type' => 'application/x-www-form-urlencoded'}
http.post(path, data, headers)
end
def self.setup_captcha(email)
resp = nil
data = nil
while true do
resp, data = GoogleAuth.login(email, random_word)
break if data.include?("Captcha")
end
[resp, data]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment