Ruby HTTParty身份验证问题

Ruby HTTParty身份验证问题,ruby,https,httparty,Ruby,Https,Httparty,我正在尝试使用HTTParty登录。 我按照指示做了,但仍然不能使它工作 require 'rubygems' require 'httparty' class LAShowRoom include HTTParty base_uri 'www.lashowroom.com' #debug_output def initialize email, password @email = email response = self.class.get('/login

我正在尝试使用HTTParty登录。 我按照指示做了,但仍然不能使它工作

require 'rubygems'
require 'httparty'

class LAShowRoom
  include HTTParty
  base_uri 'www.lashowroom.com'
  #debug_output

  def initialize email, password
    @email = email
    response = self.class.get('/login.php')
    response = self.class.post(
      '/login.php',
      :body => { :login_id => email, :login_key => password, :submit_login => 'Log In' },
      :headers => {'Cookie' => response.headers['Set-Cookie']}
    )
    @response = response
    @cookie = response.request.options[:headers]['Cookie']
  end

  def login_response
    @response
  end

  def welcome_page
    self.class.get("/announce.php", :headers => {'Cookie' => @cookie})
  end

  def logged_in?
    welcome_page.include? "Kevin"
  end
end

la_show_room = LAShowRoom.new('my_email', 'my_password')
puts "Logged in: #{la_show_room.logged_in?}"
据我所知,HTTParty自动处理https。 我错过什么了吗

谢谢


Sam

是的,HTTParty自动处理HTTPS,但您仍然需要声明HTTPS。试一试

base_uri 'https://…'
HTTParty还应该如何知道?;-)