Vkontakte¶ ↑
The easiest way to access Vkontakte API and some other utils. More info about API:
Install¶ ↑
gem 'vkontakte'
Configure¶ ↑
Vkontakte.setup do |config| config.app_id = "YOUR Vkontakte API ID" config.app_secret = "YOUR Vkontakte APP SECRET" config.format = :json config.debug = false config.logger = File.open(Rails.root.join('log', 'vkontakte.log'), "a") end
Usage¶ ↑
User API by access_token¶ ↑
user = Vkontakte::App::User.new(uid, :access_token => ACCESS_TOKEN) user.fetch # {"response"=>[{"uid"=>2592709, ...
Profile
user.profile.isAppUser # {"response"=>"1"} user.profile.getUserBalance user.profile.getUserSettings user.profile.likesGetList(:type => 'post')
Photos
user.photos.getAlbums user.photos.getAlbumsCount user.photos.get(:aid => 'album_id')
Groups
user.groups.get user.groups.isMember(:gid => 'group_id') user.groups.join(:gid => 1) user.groups.leave(:gid => 1)
Friends
user.friends.get user.friends.getOnline
Secure API¶ ↑
@app = Vkontakte::App::Secure.new @app.secure.getAppBalance # {"response"=>2000} @app.auth # {"expires_in"=>0, "access_token"=>"d173f5...319f"}
IFrame application¶ ↑
Check if auth_key is valid:
def index @app = Vkontakte::App::Iframe.new @app.params = params if @app.valid_auth_key? session[:viewer_id] = params[:viewer_id] else render :action => "failure" end end
Test¶ ↑
rake spec
Copyright © 2011 Aimbulance, released under the MIT license