Class: SocialBee::Vkontakte
- Inherits:
-
Object
- Object
- SocialBee::Vkontakte
- Includes:
- VK, YAML
- Defined in:
- lib/social-bee/vkontakte.rb
Instance Method Summary collapse
- #client(token) ⇒ Object
- #get_friends(token) ⇒ Object
-
#initialize(p = {}) ⇒ Vkontakte
constructor
A new instance of Vkontakte.
- #say_friends(message, token) ⇒ Object
- #say_private(to, message, token) ⇒ Object
- #say_public(message, token) ⇒ Object
Constructor Details
#initialize(p = {}) ⇒ Vkontakte
Returns a new instance of Vkontakte.
9 10 11 12 13 14 15 16 17 |
# File 'lib/social-bee/vkontakte.rb', line 9 def initialize(p={}) raise 'Undefined config file' unless config = YAML.load_file(Rails.root + p[:config])[Rails.env] raise 'Undefined application id' unless app_id = config['app_id'] raise 'Undefined application key' unless app_key = config['app_key'] @app = VK::Standalone.new :app_id => app_id, :app_secret => app_key end |
Instance Method Details
#client(token) ⇒ Object
19 20 21 22 |
# File 'lib/social-bee/vkontakte.rb', line 19 def client( token ) @app.access_token = token @app end |
#get_friends(token) ⇒ Object
39 40 41 |
# File 'lib/social-bee/vkontakte.rb', line 39 def get_friends( token ) client( token ).friends.get end |
#say_friends(message, token) ⇒ Object
33 34 35 36 37 |
# File 'lib/social-bee/vkontakte.rb', line 33 def say_friends( , token ) get_friends(token).each do |itm| say_private( itm, , token ) end end |
#say_private(to, message, token) ⇒ Object
29 30 31 |
# File 'lib/social-bee/vkontakte.rb', line 29 def say_private( to, , token ) client( token )..send( :uid => to, :message => ) end |
#say_public(message, token) ⇒ Object
25 26 27 |
# File 'lib/social-bee/vkontakte.rb', line 25 def say_public( , token ) client( token ).wall.post( :message => CGI::escape() ) end |