Class: Contacts::TonlineDe

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

Constant Summary collapse

DETECTED_DOMAINS =
[ /t-mobile\.de/i, /t-online\.de/i ]
URL =
"https://email.t-online.de/V4-0-4-0/srv-bin/aaa?method=deliverLoginBox"
ADDRESS_BOOK_URL =
"https://email.t-online.de/V4-0-4-0/srv-bin/addressbook?method=exportAdressbook&p%5Bformat%5D=CSV&p%5Bliid%5D="
PROTOCOL_ERROR =
"t-online.de has changed its protocols"

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/tonline_de.rb', line 8

def cookies
  @cookies
end

#tidObject

Returns the value of attribute tid.



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

def tid
  @tid
end

Instance Method Details

#contactsObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/contacts/tonline_de.rb', line 44

def contacts
  @contacts = []
  
  data, resp, self.cookies, forward = get(ADDRESS_BOOK_URL, self.cookies)      

  CSV.parse(data) do |row|
    other, first_name, last_name, email = row
    
    name = "#{first_name} #{last_name}".strip
    email.strip!

    next unless email.include?('@')

    @contacts << [name, email]
  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
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/contacts/tonline_de.rb', line 10

def real_connect
  data, resp, self.cookies, forward = get(URL, "")

  doc = Nokogiri(data)
  meta = doc.at('meta[http-equiv=refresh]')

  if meta.nil?
    raise ConnectionError, PROTOCOL_ERROR
  end

  forward = meta['content'].split('URL=').last
  
  data, resp, self.cookies, forward = get(forward, self.cookies)

  doc = Nokogiri(data)

  self.tid = doc.at('input[name=tid]')['value']
  url = doc.at('form[name=login]')['action']

  postdata =  "appid=0158&lang=de&login=Login&pwd=%s&skinid=30&tid=%s&usr=%s" % [
    CGI.escape(password),
    CGI.escape(self.tid),
    CGI.escape(username)
  ]

  data, resp, self.cookies, forward = post(url, postdata, self.cookies)
  
  if forward.nil? || !forward.match("loadUser")
    raise AuthenticationError, "Username and password do not match"
  end

  data, resp, self.cookies, forward = get(forward, self.cookies)
end

#skip_gzip?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/contacts/tonline_de.rb', line 63

def skip_gzip?
  false
end