Class: Contacts::Gmx

Inherits:
Base
  • Object
show all
Defined in:
lib/contacts/gmx.rb

Constant Summary collapse

DETECTED_DOMAINS =
[ /gmx.de/i, /gmx.at/i, /gmx.ch/i, /gmx.net/i ]
LOGIN_URL =
"https://service.gmx.net/de/cgi/login"
ADDRESS_BOOK_URL =
"https://service.gmx.net/de/cgi/g.fcgi/addressbook/cab?cc=subnavi_adressbuch&sid="
EXPORT_URL =
"https://adressbuch.gmx.net/exportcontacts"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#connect, #connected?, #initialize, #login, #password

Constructor Details

This class inherits a constructor from Contacts::Base

Instance Attribute Details

#cookiesObject

Returns the value of attribute cookies.



8
9
10
# File 'lib/contacts/gmx.rb', line 8

def cookies
  @cookies
end

#sidObject

Returns the value of attribute sid.



8
9
10
# File 'lib/contacts/gmx.rb', line 8

def sid
  @sid
end

Instance Method Details

#contactsObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/contacts/gmx.rb', line 32

def contacts
  data, resp, cookies, forward = get(ADDRESS_BOOK_URL + self.sid, self.cookies)
  data, resp, cookies, forward = get(forward, self.cookies)

  session = forward.match(/session=([^&]+)/)[1]      

  postdata = "language=eng&raw_format=csv_Outlook2003&what=PERSON&session=" + session

  data, resp, cookies, forward = post(EXPORT_URL, postdata, self.cookies)
  
  @contacts = []

  CSV.parse(data) do |row|
    @contacts << ["#{row[2]} #{row[0]}", row[9]] unless header_row?(row)
  end

  @contacts
end

#real_connectObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/contacts/gmx.rb', line 10

def real_connect

  postdata =  "AREA=1&EXT=redirect&EXT2=&dlevel=c&id=%s&p=%s&uinguserid=__uuid__" % [
    CGI.escape(),
    CGI.escape(password)
  ]

  data, resp, self.cookies, forward = post(LOGIN_URL, postdata, "")

  if data.index("lose/password")
    raise AuthenticationError, "Username and password do not match"
  elsif !forward.nil? && forward.index("login-failed")
    raise AuthenticationError, "Username and password do not match"
  elsif cookies == "" or data == ""
    raise ConnectionError, PROTOCOL_ERROR
  end

  data, resp, self.cookies, forward = get(forward, self.cookies)
  
  self.sid = data.match(/sid=([a-z0-9\.]+)/)[1]      
end

#skip_gzip?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/contacts/gmx.rb', line 51

def skip_gzip?
  false
end