social-bee 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -1
- data/lib/social-bee/facebook.rb +23 -1
- data/lib/social-bee/twi.rb +25 -6
- data/lib/social-bee/version.rb +1 -1
- data/lib/social-bee/vkontakte.rb +20 -2
- metadata +8 -8
data/.gitignore
CHANGED
data/lib/social-bee/facebook.rb
CHANGED
@@ -28,9 +28,31 @@ module SocialBee
|
|
28
28
|
|
29
29
|
end
|
30
30
|
|
31
|
+
def client( token )
|
32
|
+
Koala::Facebook::API.new( token )
|
33
|
+
end
|
34
|
+
|
31
35
|
|
32
36
|
def say_public( message, token )
|
33
|
-
|
37
|
+
client( token ).put_wall_post( message )
|
38
|
+
end
|
39
|
+
|
40
|
+
def say_private( to, message, token )
|
41
|
+
client( token ).put_object( to, 'inbox', :message => message )
|
42
|
+
end
|
43
|
+
|
44
|
+
def say_friends( message, token )
|
45
|
+
get_friends( token ).each do |itm|
|
46
|
+
say_private( itm, message, token )
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def get_friends( token )
|
51
|
+
arr = []
|
52
|
+
client( token ).get_connections('me', 'friends').each do |itm|
|
53
|
+
arr.push itm['id']
|
54
|
+
end
|
55
|
+
arr
|
34
56
|
end
|
35
57
|
|
36
58
|
|
data/lib/social-bee/twi.rb
CHANGED
@@ -7,18 +7,37 @@ module SocialBee
|
|
7
7
|
|
8
8
|
|
9
9
|
def initialize(p={})
|
10
|
-
raise 'Undefined config file' unless @config = YAML.load_file(Rails.root + p[:config])[Rails.env]
|
11
|
-
end
|
12
10
|
|
11
|
+
raise 'Undefined config file' unless @config = YAML.load_file(Rails.root + p[:config])[Rails.env]
|
13
12
|
|
14
|
-
def say_public( message, token, secret )
|
15
13
|
Twitter.configure do |config|
|
16
14
|
raise 'Undefined consumer key' unless config.consumer_key = @config['app_key']
|
17
15
|
raise 'Undefined consumer secret' unless config.consumer_secret = @config['app_secret']
|
18
|
-
raise 'Undefined user token' unless config.oauth_token = token
|
19
|
-
raise 'Undefined user secret' unless config.oauth_token_secret = secret
|
20
16
|
end
|
21
|
-
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
def client( token, secret )
|
21
|
+
Twitter::Client.new( :oauth_token => token, :oauth_token_secret => secret )
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
def say_public( message, token, secret )
|
26
|
+
client( token, secret ).update( message )
|
27
|
+
end
|
28
|
+
|
29
|
+
def say_private( to, message, token, secret )
|
30
|
+
client( token, secret ).direct_message_create( to, message )
|
31
|
+
end
|
32
|
+
|
33
|
+
def say_friends( message, token, secret )
|
34
|
+
get_friends( token, secret ).each do |itm|
|
35
|
+
say_private( itm, message, token, secret )
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def get_friends( token, secret )
|
40
|
+
client( token, secret ).follower_ids.ids
|
22
41
|
end
|
23
42
|
|
24
43
|
|
data/lib/social-bee/version.rb
CHANGED
data/lib/social-bee/vkontakte.rb
CHANGED
@@ -16,10 +16,28 @@ module SocialBee
|
|
16
16
|
|
17
17
|
end
|
18
18
|
|
19
|
+
def client( token )
|
20
|
+
@app.access_token = token
|
21
|
+
@app
|
22
|
+
end
|
23
|
+
|
19
24
|
|
20
25
|
def say_public( message, token )
|
21
|
-
|
22
|
-
|
26
|
+
client( token ).wall.post( :message => CGI::escape(message) )
|
27
|
+
end
|
28
|
+
|
29
|
+
def say_private( to, message, token )
|
30
|
+
client( token ).messages.send( :uid => to, :message => message )
|
31
|
+
end
|
32
|
+
|
33
|
+
def say_friends( message, token )
|
34
|
+
get_friends(token).each do |itm|
|
35
|
+
say_private( itm, message, token )
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def get_friends( token )
|
40
|
+
client( token ).friends.get
|
23
41
|
end
|
24
42
|
|
25
43
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: social-bee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-10-
|
12
|
+
date: 2011-10-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: twitter
|
16
|
-
requirement: &
|
16
|
+
requirement: &70206097759580 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70206097759580
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: koala
|
27
|
-
requirement: &
|
27
|
+
requirement: &70206097756100 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70206097756100
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: vk-ruby
|
38
|
-
requirement: &
|
38
|
+
requirement: &70206097755440 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70206097755440
|
47
47
|
description: Simple messaging wrapper for Facebook, Twitter, Vkontakte
|
48
48
|
email:
|
49
49
|
- atimofeev@reactant.ru
|