Class: Contacts::Sina

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

Constant Summary collapse

URL =
"http://mail.sina.com.cn"
LOGIN_URL =
{
  :sina_cn => "https://mail.sina.com.cn/cgi-bin/cnlogin.php",
  :sina_com => "https://mail.sina.com.cn/cgi-bin/login.php"
}
{
  :sina_cn => "sina_cn_mail_recid=true",
  :sina_com => "sina_free_mail_recid=true; sina_free_mail_ltype=uid; sina_vip_mail_recid=false"
}
DOMAIN =
{
  :sina_cn => 'sina.cn',
  :sina_com => 'sina.com'
}
PROTOCOL_ERROR =
"sina has changed its protocols, please upgrade this library first. you can also contact [email protected]"

Instance Method Summary collapse

Methods inherited from Base

#connect, #connected?, #login, #login_with_domain, #login_without_domain, #password

Constructor Details

#initialize(login, password, options = {}) ⇒ Sina

Returns a new instance of Sina.



18
19
20
21
# File 'lib/contacts/sina.rb', line 18

def initialize(, password, options={})
  @mail_type = get_mail_type()
  super(,password,options)
end

Instance Method Details

#contactsObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/contacts/sina.rb', line 28

def contacts
  return @contacts if @contacts
  if connected?
    data, resp, cookies, forward = get(@mail_url,@cookies)
    if resp.code_type != Net::HTTPOK
      raise ConnectionError, self.class.const_get(:PROTOCOL_ERROR)
    end
    parse(data)
  end
end

#real_connectObject



23
24
25
26
# File 'lib/contacts/sina.rb', line 23

def real_connect
  
  redirect_for_location
end