Module: Vkontakte::Status
- Included in:
- User
- Defined in:
- lib/rvk/status.rb
Instance Method Summary collapse
Instance Method Details
#fetch_activityhash ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/rvk/status.rb', line 13 def fetch_activityhash request = open('http://vk.com/profile.php', 'Cookie' => "remixsid=#{self.session}") profile = request.read.to_s if match = profile.match(/<input type='hidden' id='activityhash' value='([^']+)'>/) match[1] else raise VkontakteError, "Could not find status hash" end end |
#set_status(text) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/rvk/status.rb', line 4 def set_status text url = URI.parse('http://vk.com/profile.php') request = Net::HTTP::Post.new(url.path) request.set_form_data({'setactivity' => text, 'activityhash' => self.fetch_activityhash}) request['cookie'] = "remixsid=#{self.session}" Net::HTTP.new(url.host, url.port).start { |http| http.request(request) } end |