social_feed_agregator 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/lib/social_feed_agregator/facebook_reader.rb +51 -0
- data/lib/social_feed_agregator/feed.rb +39 -0
- data/lib/social_feed_agregator/twitter_reader.rb +79 -0
- data/lib/social_feed_agregator/version.rb +1 -1
- data/lib/social_feed_agregator.rb +9 -2
- data/social_feed_agregator.gemspec +3 -0
- metadata +33 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f548b461c4328280e0e85046aaf241f6f9083659
|
4
|
+
data.tar.gz: 2ba8f7d20acf36b32c6f20ff1ed511eac17bfeac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 064e1ccde9755477090af8a13fc159d5d6ab6d245e98882c06e48fede8a11fef2b1b22e8e86397ba21ebc39bf24c0996a6203721279f55994899372744bcf03c
|
7
|
+
data.tar.gz: fc042377bbaf949625ed7fca328b8f4dd2fbee676cf3267eb41c47f310f65d9a5428aa98e24820225a2d59ea1d8d361c18d8ce8090acb5195428ac1e5a60a857
|
data/Gemfile
CHANGED
@@ -0,0 +1,51 @@
|
|
1
|
+
require "social_feed_agregator/feed"
|
2
|
+
require "koala"
|
3
|
+
|
4
|
+
module SocialFeedAgregator
|
5
|
+
class FacebookReader
|
6
|
+
|
7
|
+
attr_accessor :app_id, :app_secret, :name
|
8
|
+
|
9
|
+
def initialize(options={})
|
10
|
+
options.replace(SocialFeedAgregator.default_options.merge(options))
|
11
|
+
|
12
|
+
@name = options[:facebook_user_name]
|
13
|
+
@app_id = options[:facebook_app_id]
|
14
|
+
@app_secret = options[:facebook_app_secret]
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_feeds(options={})
|
18
|
+
@name = options[:name] if options[:name]
|
19
|
+
|
20
|
+
oauth = Koala::Facebook::OAuth.new(@app_id, @app_secret)
|
21
|
+
graph = Koala::Facebook::API.new oauth.get_app_access_token
|
22
|
+
posts = graph.get_connections(@name, "posts")
|
23
|
+
|
24
|
+
begin
|
25
|
+
posts.map do |post|
|
26
|
+
Feed.new ({
|
27
|
+
feed_type: :facebook,
|
28
|
+
feed_id: post['id'],
|
29
|
+
|
30
|
+
user_id: post['from']['id'],
|
31
|
+
user_name: post['from']['name'],
|
32
|
+
|
33
|
+
permalink: "http://www.facebook.com/#{post['id'].gsub('_', '/posts/')}",
|
34
|
+
description: post['description'],
|
35
|
+
|
36
|
+
name: post['name'],
|
37
|
+
picture_url: post['picture'],
|
38
|
+
link: post['link'],
|
39
|
+
caption: post['caption'],
|
40
|
+
story: post['story'],
|
41
|
+
message: post['message'],
|
42
|
+
created_at: post["created_time" ],
|
43
|
+
type: post['type']
|
44
|
+
})
|
45
|
+
end
|
46
|
+
end while not posts = posts.next_page
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module SocialFeedAgregator
|
2
|
+
class Feed
|
3
|
+
|
4
|
+
attr_accessor :feed_type, # :facebook, :twitter or :linkedin
|
5
|
+
:feed_id, # origin feed id
|
6
|
+
:user_id, # user id
|
7
|
+
:user_name, # user name
|
8
|
+
:permalink,
|
9
|
+
:description,
|
10
|
+
:picture_url,
|
11
|
+
:name,
|
12
|
+
:link,
|
13
|
+
:story,
|
14
|
+
:message, # status message
|
15
|
+
:caption,
|
16
|
+
:created_at,
|
17
|
+
:type # link or status
|
18
|
+
|
19
|
+
def initialize(options={})
|
20
|
+
@feed_type = options[:feed_type]
|
21
|
+
@feed_id = options[:feed_id]
|
22
|
+
|
23
|
+
@user_id = options[:user_id]
|
24
|
+
@user_name = options[:user_name]
|
25
|
+
|
26
|
+
@permalink = options[:permalink]
|
27
|
+
@description = options[:description]
|
28
|
+
@picture_url = options[:picture_url]
|
29
|
+
|
30
|
+
@name = options[:name]
|
31
|
+
@link = options[:link]
|
32
|
+
@story = options[:story]
|
33
|
+
@message = options[:message]
|
34
|
+
@caption = options[:caption]
|
35
|
+
@created_at = options[:created_at]
|
36
|
+
@type = options[:type]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require "social_feed_agregator/feed"
|
2
|
+
require "twitter"
|
3
|
+
|
4
|
+
module SocialFeedAgregator
|
5
|
+
class TwitterReader
|
6
|
+
|
7
|
+
attr_accessor :consumer_key,
|
8
|
+
:consumer_secret,
|
9
|
+
:twitter_oauth_token,
|
10
|
+
:twitter_oauth_token_secret,
|
11
|
+
:twitter_name
|
12
|
+
|
13
|
+
def initialize(options={})
|
14
|
+
options.replace(SocialFeedAgregator.default_options.merge(options))
|
15
|
+
|
16
|
+
@consumer_key = options[:twitter_consumer_key]
|
17
|
+
@consumer_secret = options[:twitter_consumer_secret]
|
18
|
+
@oauth_token = options[:twitter_oauth_token]
|
19
|
+
@token_secret = options[:twitter_oauth_token_secret]
|
20
|
+
@name = options[:twitter_user_name]
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_feeds(options={})
|
24
|
+
@name = options[:name] if options[:name]
|
25
|
+
count = options[:count] if options[:count]
|
26
|
+
|
27
|
+
client = ::Twitter.configure do |config|
|
28
|
+
config.consumer_key = @consumer_key
|
29
|
+
config.consumer_secret = @consumer_secret
|
30
|
+
config.oauth_token = @oauth_token
|
31
|
+
config.oauth_token_secret = @token_secret
|
32
|
+
end
|
33
|
+
|
34
|
+
statuses = client.user_timeline(@name, {count: count})
|
35
|
+
|
36
|
+
statuses.map do |status|
|
37
|
+
tweet_type = 'status'
|
38
|
+
picture_url = ''
|
39
|
+
link = ''
|
40
|
+
|
41
|
+
if status.entities?
|
42
|
+
|
43
|
+
if status.media.any?
|
44
|
+
photo_entity = status.media.first
|
45
|
+
tweet_type = 'photo'
|
46
|
+
picture_url = photo_entity.media_url
|
47
|
+
end
|
48
|
+
|
49
|
+
if status.urls.any?
|
50
|
+
url_entity = status.urls.first
|
51
|
+
tweet_type = 'link'
|
52
|
+
link = url_entity.url
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
Feed.new ({
|
59
|
+
feed_type: :twitter,
|
60
|
+
feed_id: status.id.to_s,
|
61
|
+
|
62
|
+
user_id: status.user.id,
|
63
|
+
user_name: status.user.screen_name,
|
64
|
+
|
65
|
+
permalink: "https://twitter.com/#{status.user.screen_name}/status/#{status.id}", #status.url,
|
66
|
+
message: status.text,
|
67
|
+
created_at: status.created_at,
|
68
|
+
|
69
|
+
type: tweet_type,
|
70
|
+
picture_url: picture_url,
|
71
|
+
link: link
|
72
|
+
})
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
Twitter = TwitterReader
|
79
|
+
end
|
@@ -1,5 +1,12 @@
|
|
1
1
|
require "social_feed_agregator/version"
|
2
|
+
require "social_feed_agregator/facebook_reader"
|
3
|
+
require "social_feed_agregator/twitter_reader"
|
2
4
|
|
3
|
-
module SocialFeedAgregator
|
4
|
-
|
5
|
+
module SocialFeedAgregator
|
6
|
+
@default_options = {}
|
7
|
+
class << self; attr_accessor :default_options; end
|
8
|
+
|
9
|
+
class Exception < ::Exception; end
|
5
10
|
end
|
11
|
+
|
12
|
+
SFA=SocialFeedAgregator
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: social_feed_agregator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eugene Sobolev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: koala
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.6.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.6.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: twitter
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 4.6.2
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 4.6.2
|
41
69
|
description: Social Feed Agregator
|
42
70
|
email:
|
43
71
|
- eus@appfellas.co
|
@@ -51,6 +79,9 @@ files:
|
|
51
79
|
- README.md
|
52
80
|
- Rakefile
|
53
81
|
- lib/social_feed_agregator.rb
|
82
|
+
- lib/social_feed_agregator/facebook_reader.rb
|
83
|
+
- lib/social_feed_agregator/feed.rb
|
84
|
+
- lib/social_feed_agregator/twitter_reader.rb
|
54
85
|
- lib/social_feed_agregator/version.rb
|
55
86
|
- social_feed_agregator.gemspec
|
56
87
|
homepage: ''
|