require 'net/http' # ( ) app_id = '1234567' # ID , email = 'mail@example.com' password = 'qwerty' app_rights = 16383 # (16383 - ) # resp = Net::HTTP.post_form(URI.parse('http://vk.com/login.php'), {'m' => '1', 'email' => email, 'pass' => password}) cookies = resp.response['set-cookie'] remixsid = cookies.split('remixsid=')[1].split(';')[0].split(',')[0] # http://vk.com header = { "Cookie" => 'remixsid=' + remixsid } conn = Net::HTTP.new('vk.com', 80) # resp = conn.get('http://vk.com/login.php?app=' + app_id + '&layout=popup&type=browser&settings=32767', header) auth_hash = resp.body.split('var auth_hash = \'')[1].split('\';')[0] rights_hash = resp.body.split('var app_settings_hash = \'')[1].split('\';')[0] # req = '' mask = 1 14.times do if (app_rights & mask == 0) req += ('&app_settings_' + mask.to_s + '=0') else req += ('&app_settings_' + mask.to_s + '=1') end mask *= 2 end resp = conn.get('http://vk.com/apps.php?act=a_save_settings&addMember=1' + req + '&hash=' + rights_hash + '&id=' + app_id, header) # resp = conn.get('http://vk.com/login.php?act=a_auth&app=' + app_id + '&hash=' + auth_hash + '&permanent=1', header) auth_json = resp.body # API JSON puts auth_json # -
{"mid":1000xxxxx,"sid":"xxxx6ed0xxxx2516xxxx49eacd0ec30f9961c01d30d15c3152e459xxxx", "secret":"335xxxxxxx","expire":0}
Source: https://habr.com/ru/post/111430/
All Articles