2011-08-08 17 views
1

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.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を処理します。 何か不足していますか?

ありがとうございました。

サム

答えて

3

はい、HTTPartyは自動的にHTTPSを処理しますが、あなたはまだHTTPSを宣言する必要があります。試してみてください

base_uri 'https://…' 

HTTPartyは他にどのように知っていますか? ;-)