Class: Ubiquitously::Twitter::Account
- Inherits:
-
Service::Account
- Object
- Base
- Service::Account
- Ubiquitously::Twitter::Account
- Defined in:
- lib/ubiquitously/services/twitter.rb
Instance Attribute Summary
Attributes inherited from Service::Account
#credentials, #ip, #logged_in, #password, #user, #username
Instance Method Summary collapse
Methods inherited from Service::Account
#access_token, #agent, #cookies?, #credentials?, #initialize
Methods included from Account::Authorizable
Methods included from Account::Loggable
Methods included from Account::Restful
Methods inherited from Base
Methods included from SubclassableCallbacks
Constructor Details
This class inherits a constructor from Ubiquitously::Service::Account
Instance Method Details
#login ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ubiquitously/services/twitter.rb', line 6 def login # only login if we don't have cookies url = "http://localhost:4567/" hash = ::TwitterToken.(url) = {:url => hash[:url]} if raise "COOKIES" .merge!(:headers => {"Cookie" => user.(:twitter)}) page = agent.get(, [], url) else page = agent.get(, [], url) form = page.forms.first form["session[username_or_email]"] = username form["session[password]"] = password page = form.submit end if page.uri.to_s =~ /http:\/\/api\.twitter\.com\/oauth\/authenticate/i if page.links.first.href !~ /http:\/\/localhost/ page = page.forms.last.submit end end (page.title =~ /Redirecting you back to the application/i) location = URI.parse(page.links.first.href) verifier = Rack::Utils.parse_query(location.query)["oauth_verifier"] # do something with the oauth token, save it in the cookie? self.credentials = ::TwitterToken.access( :token => hash[:token], :secret => hash[:secret], :oauth_verifier => verifier ) logged_in? end |