Module: Vkontakte::Status
- Included in:
- User
- Defined in:
- lib/rvk/status.rb
Instance Method Summary collapse
Instance Method Details
#find_in_profile(regexp) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/rvk/status.rb', line 26 def find_in_profile(regexp) if match = @profile.match(regexp) match[1] else raise VkontakteError, "Could not find #{regexp}" end end |
#set_microblog_status(text) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rvk/status.rb', line 9 def set_microblog_status(text) url = URI.parse('http://vk.com/al_wall.php') request = Net::HTTP::Post.new(url.path) request.set_form_data({ 'al' => 1, 'act' => 'post', 'to_id' => find_in_profile(/"user_id":"?(\d+)"?/), 'hash' => find_in_profile(/"post_hash":"([^"]+)"/), 'message' => text, 'note_title' => '', 'status_export' => '' }) request['cookie'] = "remixsid=#{self.session}" Net::HTTP.new(url.host, url.port).start { |http| http.request(request) } end |
#set_status(text) ⇒ Object
3 4 5 6 7 |
# File 'lib/rvk/status.rb', line 3 def set_status(text) request = open('http://vk.com/profile.php', 'Cookie' => "remixsid=#{self.session}") @profile = request.read.to_s set_microblog_status(text) end |