2012-04-26 09:23:47 +00:00
|
|
|
class OtheraccountsController< ApplicationController
|
2012-04-26 06:47:49 +00:00
|
|
|
require 'open-uri'
|
|
|
|
require 'rexml/document'
|
|
|
|
require 'net/http'
|
|
|
|
require 'net/https'
|
|
|
|
include REXML
|
|
|
|
|
2012-04-26 13:30:13 +00:00
|
|
|
def saveaccountinfo
|
|
|
|
@email = params['email']
|
|
|
|
@password = params['password']
|
|
|
|
@account = params['account']
|
|
|
|
OtherAccount.new(email: @email, encrypted_password: @password, type: @account)
|
|
|
|
end
|
|
|
|
|
2012-04-26 09:23:47 +00:00
|
|
|
def gmail
|
2012-04-26 06:47:49 +00:00
|
|
|
url = URI.parse("https://mail.google.com/mail/feed/atom")
|
|
|
|
req = Net::HTTP::Get.new(url.path)
|
|
|
|
req.basic_auth params['username'], params['password']
|
|
|
|
req.content_type = 'text/xml'
|
|
|
|
|
|
|
|
http = Net::HTTP.new(url.host, url.port)
|
|
|
|
http.use_ssl = true
|
|
|
|
response = http.start { |http| http.request(req) }
|
|
|
|
|
|
|
|
root = Document.new(response.read_body).root
|
|
|
|
render :text=>root
|
|
|
|
end
|
|
|
|
end
|