module PIAPRO::Auth

CA_FILE = “piapro.crt”

Constants

LOGIN_PAGE

Public Class Methods

auth(user, passwd, auto_login = nil) click to toggle source
# File core/lib/piapro.rb, line 25
def self.auth(user, passwd, auto_login = nil)
  https = Net::HTTP.new("piapro.jp", 443)
  https.use_ssl      = true
  # https.ca_file      = CA_FILE
  # https.verify_mode  = OpenSSL::SSL::VERIFY_PEER
  # https.verify_depth = 5
  https.start {|session|
    post_login = Net::HTTP::Service.new("/login/")
    post_login["User-Agent"] = USER_AGENT
    post_login["Referer"]    = REFERER
    post_login.set_form_data(
                             {
                               :mode           => "exe",
                               :login_url      => LOGIN_PAGE,
                               :login_email    => user,
                               :login_password => passwd,
                               :auto_login     => auto_login # 1 is Auto Login ON,
                             }
                             )
    response = session.request(post_login)
    @cookie  = response["Set-Cookie"]
  }
  return @cookie
end
logout(cookie) click to toggle source
# File core/lib/piapro.rb, line 50
def self.logout(cookie)
  open("http://piapro.jp/logout/?mode=exe",
       "User-Agent" => USER_AGENT,
       "Cookie"     => @cookie,
       "Referer"    => REFERER
       ){|f|
    return f.read
  }
end