class PicasaWebAlbums::Repository
Public Class Methods
new(email, password)
click to toggle source
# File lib/repositories/repository.rb, line 14 def initialize(email, password) @email = email @authentication_token = get_authentication_token(email, password) end
Private Instance Methods
get_authentication_token(email, password)
click to toggle source
# File lib/repositories/repository.rb, line 31 def get_authentication_token(email, password) uri = URI("https://www.google.com/accounts/ClientLogin") body = "" Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http| request = Net::HTTP::Post.new uri.request_uri data = "accountType=HOSTED_OR_GOOGLE&Email=#{email}&Passwd=#{password}&service=lh2&source=someapp1" response = http.request(request, data) body = response.body end start_index = body.index('Auth=') slice_of_auth_to_end = body[start_index..-1] end_index = slice_of_auth_to_end.index("\n") auth_string = slice_of_auth_to_end[0...end_index] "GoogleLogin #{auth_string}" end
get_xml(url)
click to toggle source
# File lib/repositories/repository.rb, line 21 def get_xml(url) uri = URI(url) request = Net::HTTP::Get.new(uri.request_uri) request['Authorization'] = @authentication_token response = Net::HTTP.start(uri.hostname, uri.port) { |http| http.request(request) } REXML::Document.new(response.body) end