Class: Vkontakte::User
Instance Attribute Summary collapse
-
#session ⇒ Object
Returns the value of attribute session.
Instance Method Summary collapse
- #fetch_session(email, password) ⇒ Object
-
#initialize(*args) ⇒ User
constructor
A new instance of User.
Methods included from Note
Methods included from Status
#find_in_profile, #set_microblog_status, #set_status
Constructor Details
#initialize(*args) ⇒ User
Returns a new instance of User.
8 9 10 11 12 13 14 |
# File 'lib/rvk/user.rb', line 8 def initialize(*args) if (args.size == 1) self.session = args.first else self.session = self.fetch_session *args end end |
Instance Attribute Details
#session ⇒ Object
Returns the value of attribute session.
3 4 5 |
# File 'lib/rvk/user.rb', line 3 def session @session end |
Instance Method Details
#fetch_session(email, password) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rvk/user.rb', line 16 def fetch_session(email, password) resource = Net::HTTP.post_form(URI.parse('http://login.vk.com/'), { 'email' => email, 'pass' => password, 'vk' => '', 'act' => 'login' }) if resource.body.empty? raise VkontakteError, "Could not fetch session" end if match = resource.body.match(/name='s' value='([a-z0-9]+)'/) match[1] else raise VkontakteError, "Could not find session" end end |