liangzan-contacts 1.2.11 → 1.2.12

Sign up to get free protection for your applications and to get access to all the features.
data/lib/contacts/aol.rb CHANGED
@@ -6,10 +6,10 @@ class Contacts
6
6
  LOGIN_URL = "https://my.screenname.aol.com/_cqr/login/login.psp"
7
7
  LOGIN_REFERER_URL = "http://webmail.aol.com/"
8
8
  LOGIN_REFERER_PATH = "sitedomain=sns.webmail.aol.com&lang=en&locale=us&authLev=0&uitype=mini&loginId=&redirType=js&xchk=false"
9
- AOL_NUM = "29970-343" # this seems to change each time they change the protocol
9
+ AOL_NUM = "35752-111" # this seems to change each time they change the protocol
10
10
 
11
- CONTACT_LIST_URL = "http://webmail.aol.com/#{AOL_NUM}/aim-2/en-us/Lite/ContactList.aspx?folder=Inbox&showUserFolders=False"
12
- CONTACT_LIST_CSV_URL = "http://webmail.aol.com/#{AOL_NUM}/aim-2/en-us/Lite/ABExport.aspx?command=all"
11
+ CONTACT_LIST_URL = "http://mail.aol.com/#{AOL_NUM}/aol-6/en-us/Lite/ContactList.aspx"
12
+ CONTACT_LIST_CSV_URL = "http://mail.aol.com/#{AOL_NUM}/aol-6/en-us/Lite/ABExport.aspx?command=all"
13
13
  PROTOCOL_ERROR = "AOL has changed its protocols, please upgrade this library first. If that does not work, dive into the code and submit a patch at http://github.com/cardmagic/contacts"
14
14
 
15
15
  def real_connect
@@ -63,9 +63,9 @@ class Contacts
63
63
  data, resp, cookies, forward, old_url = get(forward, cookies, old_url) + [forward]
64
64
  end
65
65
 
66
- doc = Hpricot(data)
67
- (doc/:input).each do |input|
68
- postdata["usrd"] = input.attributes["value"] if input.attributes["name"] == "usrd"
66
+ doc = Nokogiri(data)
67
+ (doc/'input[name=usrd]').each do |input|
68
+ postdata["usrd"] = input['value']
69
69
  end
70
70
  # parse data for <input name="usrd" value="2726212" type="hidden"> and add it to the postdata
71
71
 
@@ -80,7 +80,7 @@ class Contacts
80
80
  data, resp, cookies, forward, old_url = get(forward, cookies, old_url) + [forward]
81
81
  end
82
82
 
83
- if data.index("Invalid Username or Password. Please try again.")
83
+ if data.index("Incorrect Username or Password.")
84
84
  raise AuthenticationError, "Username and password do not match"
85
85
  elsif data.index("Required field must not be blank")
86
86
  raise AuthenticationError, "Login and password must not be blank"
@@ -112,13 +112,15 @@ class Contacts
112
112
  if resp.code_type != Net::HTTPOK
113
113
  raise ConnectionError, self.class.const_get(:PROTOCOL_ERROR)
114
114
  end
115
+
116
+ user = nil
115
117
 
116
118
  # parse data and grab <input name="user" value="8QzMPIAKs2" type="hidden">
117
- doc = Hpricot(data)
118
- (doc/:input).each do |input|
119
- postdata["user"] = input.attributes["value"] if input.attributes["name"] == "user"
119
+ doc = Nokogiri(data)
120
+ (doc/'input[name=user]').each do |input|
121
+ user = input["value"]
120
122
  end
121
-
123
+
122
124
  data, resp, cookies, forward, old_url = get(CONTACT_LIST_CSV_URL, @cookies, CONTACT_LIST_URL) + [CONTACT_LIST_URL]
123
125
 
124
126
  until forward.nil?
@@ -135,7 +137,7 @@ class Contacts
135
137
  private
136
138
 
137
139
  def parse(data, options={})
138
- data = CSV::Reader.parse(data)
140
+ data = CSV.parse(data)
139
141
  col_names = data.shift
140
142
  @contacts = data.map do |person|
141
143
  ["#{person[0]} #{person[1]}", person[4]] if person[4] && !person[4].empty?
data/lib/contacts/base.rb CHANGED
@@ -165,6 +165,8 @@ class Contacts
165
165
  data = uncompress(resp)
166
166
  cookies = parse_cookies(resp.response['set-cookie'], cookies)
167
167
  forward = resp.response['Location']
168
+ forward.gsub!(' ', '%20') unless forward.nil?
169
+
168
170
  if (not forward.nil?) && URI.parse(forward).host.nil?
169
171
  forward = url.scheme.to_s + "://" + url.host.to_s + forward
170
172
  end
@@ -3,7 +3,7 @@ require 'csv'
3
3
  class Contacts
4
4
  class Mailru < Base
5
5
  LOGIN_URL = "https://auth.mail.ru/cgi-bin/auth"
6
- ADDRESS_BOOK_URL = "http://win.mail.ru/cgi-bin/abexport/addressbook.csv"
6
+ ADDRESS_BOOK_URL = "http://e.mail.ru/cgi-bin/abexport/addressbook.csv"
7
7
 
8
8
  attr_accessor :cookies
9
9
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liangzan-contacts
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.11
4
+ version: 1.2.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,11 +13,11 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2012-03-13 00:00:00.000000000Z
16
+ date: 2012-03-14 00:00:00.000000000Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: json
20
- requirement: &4012780 !ruby/object:Gem::Requirement
20
+ requirement: &4670300 !ruby/object:Gem::Requirement
21
21
  none: false
22
22
  requirements:
23
23
  - - ~>
@@ -25,10 +25,10 @@ dependencies:
25
25
  version: 1.6.5
26
26
  type: :runtime
27
27
  prerelease: false
28
- version_requirements: *4012780
28
+ version_requirements: *4670300
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: gdata_19
31
- requirement: &4011260 !ruby/object:Gem::Requirement
31
+ requirement: &4669020 !ruby/object:Gem::Requirement
32
32
  none: false
33
33
  requirements:
34
34
  - - ~>
@@ -36,10 +36,10 @@ dependencies:
36
36
  version: 1.1.3
37
37
  type: :runtime
38
38
  prerelease: false
39
- version_requirements: *4011260
39
+ version_requirements: *4669020
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: nokogiri
42
- requirement: &4010340 !ruby/object:Gem::Requirement
42
+ requirement: &4667900 !ruby/object:Gem::Requirement
43
43
  none: false
44
44
  requirements:
45
45
  - - ~>
@@ -47,7 +47,7 @@ dependencies:
47
47
  version: 1.5.0
48
48
  type: :runtime
49
49
  prerelease: false
50
- version_requirements: *4010340
50
+ version_requirements: *4667900
51
51
  description: A universal interface to grab contact list information from various providers
52
52
  including Yahoo, AOL, Gmail, Hotmail, and Plaxo. Now supporting Ruby 1.9.
53
53
  email: zan@liangzan.net