Class: Contacts::Aol
Constant Summary collapse
- URL =
"http://www.aol.com/"
- LOGIN_URL =
"https://my.screenname.aol.com/_cqr/login/login.psp"
- LOGIN_REFERER_URL =
"http://webmail.aol.com/"
- LOGIN_REFERER_PATH =
"sitedomain=sns.webmail.aol.com&lang=en&locale=us&authLev=0&uitype=mini&loginId=&redirType=js&xchk=false"
- AOL_NUM =
this seems to change each time they change the protocol
"29970-343"
- CONTACT_LIST_URL =
"http://webmail.aol.com/#{AOL_NUM}/aim-2/en-us/Lite/ContactList.aspx?folder=Inbox&showUserFolders=False"
- CONTACT_LIST_CSV_URL =
"http://webmail.aol.com/#{AOL_NUM}/aim-2/en-us/Lite/ABExport.aspx?command=all"
- 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"
Instance Method Summary collapse
Methods inherited from Base
#connect, #connected?, #initialize, #login, #password, #skip_gzip?
Constructor Details
This class inherits a constructor from Contacts::Base
Instance Method Details
#contacts ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/contacts/aol.rb', line 98 def contacts postdata = { "file" => 'contacts', "fileType" => 'csv' } return @contacts if @contacts if connected? data, resp, , forward, old_url = get(CONTACT_LIST_URL, @cookies, CONTACT_LIST_URL) + [CONTACT_LIST_URL] until forward.nil? data, resp, , forward, old_url = get(forward, , old_url) + [forward] end if resp.code_type != Net::HTTPOK raise ConnectionError, self.class.const_get(:PROTOCOL_ERROR) end # parse data and grab <input name="user" value="8QzMPIAKs2" type="hidden"> doc = Hpricot(data) (doc/:input).each do |input| postdata["user"] = input.attributes["value"] if input.attributes["name"] == "user" end data, resp, , forward, old_url = get(CONTACT_LIST_CSV_URL, @cookies, CONTACT_LIST_URL) + [CONTACT_LIST_URL] until forward.nil? data, resp, , forward, old_url = get(forward, , old_url) + [forward] end if data.include?("error.gif") raise AuthenticationError, "Account invalid" end parse data end end |
#real_connect ⇒ Object
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/contacts/aol.rb', line 15 def real_connect if login.strip =~ /^(.+)@aol\.com$/ # strip off the @aol.com for AOL logins login = $1 end postdata = { "loginId" => login, "password" => password, "rememberMe" => "on", "_sns_fg_color_" => "", "_sns_err_color_" => "", "_sns_link_color_" => "", "_sns_width_" => "", "_sns_height_" => "", "offerId" => "mail-second-en-us", "_sns_bg_color_" => "", "sitedomain" => "sns.webmail.aol.com", "regPromoCode" => "", "mcState" => "initialized", "uitype" => "std", "siteId" => "", "lang" => "en", "locale" => "us", "authLev" => "0", "siteState" => "", "isSiteStateEncoded" => "false", "use_aam" => "0", "seamless" => "novl", "aolsubmit" => CGI.escape("Sign In"), "idType" => "SN", "usrd" => "", "doSSL" => "", "redirType" => "", "xchk" => "false" } # Get this cookie and stick it in the form to confirm to Aol that your cookies work data, resp, , forward = get(URL) postdata["stips"] = ()["stips"] postdata["tst"] = ()["tst"] data, resp, , forward, old_url = get(LOGIN_REFERER_URL, ) + [URL] until forward.nil? data, resp, , forward, old_url = get(forward, , old_url) + [forward] end data, resp, , forward, old_url = get("#{LOGIN_URL}?#{LOGIN_REFERER_PATH}", ) + [LOGIN_REFERER_URL] until forward.nil? data, resp, , forward, old_url = get(forward, , old_url) + [forward] end doc = Hpricot(data) (doc/:input).each do |input| postdata["usrd"] = input.attributes["value"] if input.attributes["name"] == "usrd" end # parse data for <input name="usrd" value="2726212" type="hidden"> and add it to the postdata postdata["SNS_SC"] = ()["SNS_SC"] postdata["SNS_LDC"] = ()["SNS_LDC"] postdata["LTState"] = ()["LTState"] # raise data.inspect data, resp, , forward, old_url = post(LOGIN_URL, h_to_query_string(postdata), , LOGIN_REFERER_URL) + [LOGIN_REFERER_URL] until forward.nil? data, resp, , forward, old_url = get(forward, , old_url) + [forward] end if data.index("Invalid Username or Password. Please try again.") 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 == "" raise ConnectionError, PROTOCOL_ERROR end @cookies = end |