【问题标题】:HTTParty authentication problemHTTParty 认证问题
【发布时间】:2012-03-27 14:59:23
【问题描述】:

我正在尝试使用 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。 我错过了什么吗?

谢谢。

山姆

【问题讨论】:

    标签: ruby https httparty


    【解决方案1】:

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

    base_uri 'https://…'
    

    HTTParty 还应该知道什么? ;-)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-03-11
      • 1970-01-01
      • 2011-05-02
      • 2020-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多