12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/contacts/gmail.rb', line 12
def real_connect
postdata = "ltmpl=yj_blanco"
postdata += "&continue=%s" % CGI.escape(URL)
postdata += "<mplcache=2"
postdata += "&service=mail"
postdata += "&rm=false"
postdata += "<mpl=yj_blanco"
postdata += "&hl=en"
postdata += "&Email=%s" % CGI.escape(login)
postdata += "&Passwd=%s" % CGI.escape(password)
postdata += "&rmShown=1"
postdata += "&null=Sign+in"
time = Time.now.to_i
time_past = Time.now.to_i - 8 - rand(12)
cookie = "GMAIL_LOGIN=T#{time_past}/#{time_past}/#{time}"
data, resp, cookies, forward, old_url = post(LOGIN_URL, postdata, cookie, LOGIN_REFERER_URL) + [LOGIN_URL]
cookies = remove_cookie("GMAIL_LOGIN", cookies)
if data.index("Username and password do not match")
raise AuthenticationError, "Username and password do not match"
elsif data.index("Required field must not be blank")
raise AuthenticationError, "Login and password must not be blank"
elsif data.index("errormsg_0_logincaptcha")
raise AuthenticationError, "Captcha error"
elsif data.index("Invalid request")
raise ConnectionError, PROTOCOL_ERROR
elsif cookies == ""
raise ConnectionError, PROTOCOL_ERROR
end
cookies = remove_cookie("LSID", cookies)
cookies = remove_cookie("GV", cookies)
@cookies = cookies
end
|